# On the commandline perl -0wne'print "$_\n" for /img\s+src="([^"]+)"/igsm' filename #### # Since HTML tags can be split into multiple lines, you need all the # content as one string open Fh, "<", "filename" or die "filename: $!\n"; my $file = do { local $/; }; close Fh; for ($file =~ /img\s+src="([^"]+)"/igsm){ print "$_\n"; }