in reply to Continue reading regex to next line
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Continue reading regex to next line
by learningperl01 (Beadle) on Mar 02, 2009 at 22:11 UTC | |
by ELISHEVA (Prior) on Mar 02, 2009 at 22:32 UTC | |
by kennethk (Abbot) on Mar 02, 2009 at 23:15 UTC |