in reply to Re: Repeated code blocks in long and hairy regex
in thread Repeated code blocks in long and hairy regex
I got the idea from an online O'Reilly book about "Mastering Perl" here: https://www.oreilly.com/library/view/mastering-perl/9780596527242/ch02.html
Here is the code example that I had seen on that page:
#!/usr/bin/perl # perl-grep2.pl my $pattern = shift @ARGV; my $regex = eval { qr/$pattern/ }; die "Check your pattern! $@" if $@; while( <> ) { print if m/$regex/; }
I didn't know why my code had had issues to begin with, so when I saw that code example, I thought perhaps I had not used the correct syntax for this usage, and tried it the way they had it. I didn't have anything to lose in trying, but the result was not an improvement.
Blessings,
~Polyglot~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Repeated code blocks in long and hairy regex
by Corion (Patriarch) on Nov 05, 2023 at 11:23 UTC | |
by Polyglot (Chaplain) on Nov 05, 2023 at 12:04 UTC | |
by Corion (Patriarch) on Nov 05, 2023 at 13:58 UTC | |
by Polyglot (Chaplain) on Nov 05, 2023 at 14:18 UTC | |
by Corion (Patriarch) on Nov 05, 2023 at 14:26 UTC |