use strict; use Regexp::Common qw /URI/; my $big_string; while () { chomp; $big_string .= $_; } my @websites = $big_string =~ m/($RE{URI}{HTTP})/g; print join "\n", @websites; __DATA__ This is a test this is a test test test http://www.website. com/getme.html this is test this is a test This is a test this is a test test test http://www.website2.com/ getme.html this is test this is a test This is a test this is a test test test http://www.website3.com/getme .html this is test this is a test This is a test this is a test test test http://www.website4.com/getme.h tml this is test this is a test