From lembark at wrkhors.com Mon Jan 8 20:36:03 2024 From: lembark at wrkhors.com (Steven Lembark) Date: Mon, 8 Jan 2024 23:36:03 -0500 Subject: [Chicago-talk] What does dollar sign followed by a period represent? In-Reply-To: <214554ED-2184-4C19-8190-15756691CCCD@petdance.com> References: <1703372256.skeqe1mkkksk8cck@hostingemail.digitalspace.net> <214554ED-2184-4C19-8190-15756691CCCD@petdance.com> Message-ID: <20240108233603.6ab5bb80.lembark@wrkhors.com> On Sat, 23 Dec 2023 16:59:24 -0600 Andy Lester wrote: > It?s the current line number. See ?perldoc perlvar? Not quite. It's the current line from the currently open file. If you are reading from mutliple files on stdin using readline, for example, it's not monotonic. In particular it cannot be used to identify the line read for an error unless you also dump the file from which the last filehandle read is open to. Not referencing the input file with $. is a common mistake. -- Steven Lembark Workhorse Computing lembark at wrkhors.com +1 888 359 3508 From sean at blanton.com Tue Jan 9 05:26:50 2024 From: sean at blanton.com (Sean Blanton) Date: Tue, 9 Jan 2024 07:26:50 -0600 Subject: [Chicago-talk] What does dollar sign followed by a period represent? In-Reply-To: References: <1703372256.skeqe1mkkksk8cck@hostingemail.digitalspace.net> Message-ID: Small thing? I don?t use the word ?scripts? anymore. They are programs and as you say they should be treated as such. I?ve found if something is called a script, people will lower their code quality standards. The name even suggests it?s no more than a sequence of commands For Junior programmers or ops or testing people, having them write ?programs? makes them feel empowered and more integrated into the team with developers. Some companies have this hierarchy or wall between developers and support people No, this is not something dramatic and may not apply to all people or all teams - it?s subtle, but I?ve seen it chip away at the stress of non-fte developers who are struggling to write code in support roles It can help communicate your standard process also - ?there are no scripts anymore. Everyone writes programs and all programs go through code review!? Then you?ve also eliminated a whole category of IT asset that needs to be managed. Hth Regards, Sean Sean Blanton sean at blanton.com On Wed, Dec 27, 2023 at 12:22 PM J L wrote: > 1. Have code reviews with pass/fail prior to committing code to a release > (yes, scripts should be considered software and as such subject to release > cycles) > 2. If you cannot, at first glance, understand a regex during this then, > 2.1 Save it using a meaningful variable with qr and then use it > 2.2 Use the /x modifier and document it ( > https://perldoc.perl.org/perlre#%2Fx-and-%2Fxx ) > 3. Store metrics on how long your organization spends per quarter/year on > problems like this one and adopt structural practices to reduce/eliminate > them. I have found the #1 waster is failing to use a well tested CPAN > module that does a better job in lieu of barely tested (and, no surprise, > largely undocumented) code that 'promised' to save time. > > People are trying to avoid/refactor Perl scripts because they beleive that > six months down the road they will inevitably fall into this type of > problem. The fact is however there have been several ways to avoid it in > the core language available for decades. > > On Sat, Dec 23, 2023, 4:57 PM Richard Reina > wrote: > >> >> A few years ago I hastily wrote some code that I did not comment very >> well. In it I found: >> >> $switch = $. if m!^[0-3]?[0-9]/[0-3]?[0-9]/(?:[0-9]{2})?[0-9]{2}$!; # >> match date >> >> Can anyone tell me what $. means? >> >> Thanks for any help. >> >> Richard >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> https://mail.pm.org/mailman/listinfo/chicago-talk >> > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > https://mail.pm.org/mailman/listinfo/chicago-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Sat Jan 20 12:24:35 2024 From: richard at rushlogistics.com (Richard Reina) Date: Sat, 20 Jan 2024 15:24:35 -0500 Subject: [Chicago-talk] Help with regex Message-ID: <1705782275.50tsk6n6m8cgk4o0@hostingemail.digitalspace.net> Good day fellow perl mongers, I have a bunch of email addresses that have been corrupted with digits (mostly dates) stuck to the end. such as smagill at abcco.com12/19/1198 I am trying to figure out what kind of regex I can use to remove the numbers and recover the pure email address. I initially thought of something like $email =~ s/^\\D*\\d+//; but that didn't work and I quickly realized that even if it had it would fail if there were a digit in the email address. Any help would be greatly appreciated. Richard From richard at rushlogistics.com Sat Jan 20 12:40:58 2024 From: richard at rushlogistics.com (Richard Reina) Date: Sat, 20 Jan 2024 15:40:58 -0500 Subject: [Chicago-talk] Help with regex In-Reply-To: <4b38e790-5175-4e07-aa41-a03b82e86223@earthlink.net> References: <1705782275.50tsk6n6m8cgk4o0@hostingemail.digitalspace.net> <4b38e790-5175-4e07-aa41-a03b82e86223@earthlink.net> Message-ID: <1705783258.gewlo4vh2c04cgwc@hostingemail.digitalspace.net> Mike, Thanks for the quick reply but perl -e 'my $em = "smagill\@abcco.com1/15/1998"; my $em =~ s/([\d\\])+$//; print "EMAIL: $em\n";' gives me: Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE [\d\\]+$/ at -e line 1. Tried adding a ) after +$ but that just gives me an empty string for $em. Maybe I'm doing something wrong? On Sat, 20 Jan 2024 14:28:52 -0600, Mike Raffety wrote: s/([\d\\]+$//; Richard Reina wrote on 1/20/2024 2:24 PM: > Good day fellow perl mongers, > > I have a bunch of email addresses that have been corrupted with digits (mostly dates) stuck to the end. such as smagill at abcco.com12/19/1198 I am trying to figure out what kind of regex I can use to remove the numbers and recover the pure email address. I initially thought of something like > > $email =~ s/^\\D*\\d+//; > > but that didn't work and I quickly realized that even if it had it would fail if there were a digit in the email address. > > Any help would be greatly appreciated. > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > https://mail.pm.org/mailman/listinfo/chicago-talk ? From drench at gmail.com Sat Jan 20 12:48:18 2024 From: drench at gmail.com (Daniel Rench) Date: Sat, 20 Jan 2024 14:48:18 -0600 Subject: [Chicago-talk] Help with regex In-Reply-To: <1705783258.gewlo4vh2c04cgwc@hostingemail.digitalspace.net> References: <1705782275.50tsk6n6m8cgk4o0@hostingemail.digitalspace.net> <4b38e790-5175-4e07-aa41-a03b82e86223@earthlink.net> <1705783258.gewlo4vh2c04cgwc@hostingemail.digitalspace.net> Message-ID: You?re close. I tweaked it slightly, and it works for me: % perl -e 'my $em = "smagill\@abcco.com1/15/1998"; $em =~ s#[\d/]+$##; print "EMAIL: $em\n";' EMAIL: smagill at abcco.com The concept is the same: work from the end, not the start of the string. I removed the parens since you don?t need them, and changed the / to # to avoid ?leaning toothpicks? \/. On Sat, Jan 20, 2024 at 2:41?PM Richard Reina wrote: > Mike, Thanks for the quick reply but > > perl -e 'my $em = "smagill\@abcco.com1/15/1998"; my $em =~ s/([\d\\])+$//; > print "EMAIL: $em\n";' > > > > > gives me: > > Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE [\d\\]+$/ at -e > line 1. > > Tried adding a ) after +$ but that just gives me an empty string for $em. > Maybe I'm doing something wrong? > > > > On Sat, 20 Jan 2024 14:28:52 -0600, Mike Raffety < > MikeRaffety at earthlink.net> wrote: > > s/([\d\\]+$//; > > Richard Reina wrote on 1/20/2024 2:24 PM: > > Good day fellow perl mongers, > > > > I have a bunch of email addresses that have been corrupted with digits > (mostly dates) stuck to the end. such as smagill at abcco.com12/19/1198 I am > trying to figure out what kind of regex I can use to remove the numbers and > recover the pure email address. I initially thought of something like > > > > $email =~ s/^\\D*\\d+//; > > > > but that didn't work and I quickly realized that even if it had it would > fail if there were a digit in the email address. > > > > Any help would be greatly appreciated. > > > > Richard > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > https://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > https://mail.pm.org/mailman/listinfo/chicago-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Sat Jan 20 13:13:46 2024 From: richard at rushlogistics.com (Richard Reina) Date: Sat, 20 Jan 2024 16:13:46 -0500 Subject: [Chicago-talk] Help with regex In-Reply-To: References: <1705782275.50tsk6n6m8cgk4o0@hostingemail.digitalspace.net> <4b38e790-5175-4e07-aa41-a03b82e86223@earthlink.net> <1705783258.gewlo4vh2c04cgwc@hostingemail.digitalspace.net> Message-ID: <1705785226.zra6kj7cpwgs8scs@hostingemail.digitalspace.net> Daniel you're a genius! Thank you so much! ? On Sat, 20 Jan 2024 14:48:18 -0600, Daniel Rench wrote: ? ? You?re close. I tweaked it slightly, and it works for me: % perl -e 'my $em = "smagill\@abcco.com1/15/1998"; $em =~ s#[\d/]+$##; print "EMAIL: $em\n";' EMAIL: smagill at abcco.com The concept is the same: work from the end, not the start of the string. I removed the parens since you don?t need them, and changed the / to # to avoid ?leaning toothpicks? \/. ? ? ? On Sat, Jan 20, 2024 at 2:41?PM Richard Reina wrote: Mike, Thanks for the quick reply but perl -e 'my $em = "smagill\@abcco.com1/15/1998"; my $em =~ s/([\d\\])+$//; print "EMAIL: $em\n";' gives me: Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE [\d\\]+$/ at -e line 1. Tried adding a ) after +$ but that just gives me an empty string for $em. Maybe I'm doing something wrong? On Sat, 20 Jan 2024 14:28:52 -0600, Mike Raffety wrote: s/([\d\\]+$//; Richard Reina wrote on 1/20/2024 2:24 PM: > Good day fellow perl mongers, > > I have a bunch of email addresses that have been corrupted with digits (mostly dates) stuck to the end. such as smagill at abcco.com12/19/1198 I am trying to figure out what kind of regex I can use to remove the numbers and recover the pure email address. I initially thought of something like > > $email =~ s/^\\D*\\d+//; > > but that didn't work and I quickly realized that even if it had it would fail if there were a digit in the email address. > > Any help would be greatly appreciated. > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > https://mail.pm.org/mailman/listinfo/chicago-talk ? _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org https://mail.pm.org/mailman/listinfo/chicago-talk _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org https://mail.pm.org/mailman/listinfo/chicago-talk -------------- next part -------------- An HTML attachment was scrubbed... URL: