in reply to REGEX issue

It is very difficult to parse HTML using regular expressions. You will be better off using a module that understands HTML better than regexen. I usually use HTML::TreeBuilder.

It is very difficult to parse XML using regular expressions. You will be better off using a module that understands XML better than regexen. I usually use XML::Simple.

use XML::Simple; my $str = "<story> <page> <description> desc </description> <image> notExpected.jpg </image> <headline> head </headline> </page> </story> <image>correctImage.jpg</image>"; my $xml = XMLin( "<wrapper>$str</wrapper>" ); my $image = $xml->{image}; print "$_\n" for ref( $image ) ? @{$image} : $image;

Notice that XML must within a single tag. Hence the addition of <wrapper>...<wrapper>

You're not using [...] character classes correctly.

See perlre, perlretut for more details.

edit: I guess I wasn't properly awake. I didn't notice it was XML rather than HTML.
edit^2: Added code