in reply to Re: Use global flag when declaring regular expressions with qr?
in thread Use global flag when declaring regular expressions with qr?
I hope you're using use strict; use warnings; or equivalent, but simply left it out for brevity.
Yes, of course, that's one of the very first things that I learned! The rest of the code is just a bunch of regular expressions. Although I'm not using use v5.10, didn't know it was necessary. I would've guessed that the code runs at the same version as the interpreter does.
Thank you for all these tips. With the main issue out of the way, all that's left is refactor into a nice looking script with more options. On that note, how would I implement it such that I could either provide any number of files, or read from standard input? This is what I came up with (should I open a new question for this?):
sub match_url { my $row = shift @_; while ($row =~ /$re/g) { say "$&"; } } if ( !@ARGV || $ARGV[0] eq "-") { @ARGV = <STDIN>; chomp(@ARGV); match_url(@ARGV); } else { # Do I need to handle the error case with this syntax? while (<>) { chomp $_; match_url($_); } }
Again, thank you all for your input!
|
|---|