You cannot get your regex to match across newlines since your input is breaking on them. One solution would be to change your input record separator by setting $/. You could then get your desired result with a code like:
#!/usr/bin/perl use strict; use warnings; undef $/; open my $fh, "<", '/tmp/sub_url_test/'; my $string = <$fh>; $string =~ s/\n//g; while ($string =~ /(http:\S*)\s/g) { print $1, "\n"; }
Update: Note, as per ELISHEVA comment, the trailing \s might bite you. I've copied the regex in the original post and for this reason am leaving it as is, but beware that this might not do what you want if your data set differs significantly from what you posted.
In reply to Re: Continue reading regex to next line
by kennethk
in thread Continue reading regex to next line
by learningperl01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |