use strict; use warnings; undef $/; my $string = ; $string =~ s/\n//g; while ($string =~ /(http:\S*)\s/g) { print $1, "\n"; } __DATA__ http://www.baz.com xxx more junk http://www.foo.com http://www.fiddle.com