in reply to Regex to "wrap" a <span around an image.

Assuming that you're looking for every image name within the file:

# On the commandline perl -0wne'print "$_\n" for /img\s+src="([^"]+)"/igsm' filename

If you're doing this within a script:

# 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 $/; <Fh> }; close Fh; for ($file =~ /img\s+src="([^"]+)"/igsm){ print "$_\n"; }

Update: Whoops, I appear to have misread what was being asked, and gave a solution to something different. As JavaFan said, the right answer is to use one of the available modules.


--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf