I have some text with images and want to grab the first image only and include that with the print out of the first sentence.
This is as far as I've got. I can see the sentence okay, but not the image.
How do I grab the image?
Thanks in advance.
This is as far as I've got. I can see the sentence okay, but not the image.
Code:
# -- Get first image (do not use module) use strict; use warnings; print "Content-type: text/html\n\n"; my $imget = '<img(.+?>)'; ## may not be right my @data = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. <img src=aaa.jpg> blah-blah-blah <img src=bbb.jpg> blah-blah-blah"; my @abc = (@data =~ m/(\w+)\s+$imget\b/gi); # get all images - may not be right my $abc = $abc[1]; print qq ~$abc Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n~; exit;
Thanks in advance.
Comment