http://www.perlmonks.org?node_id=853700

Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:

I've got to parse a string which contains variations on the following (along with some other stuff which I can ignore):

I need to extract those things, and I need to be sure the order they appear in, because if there's only one, it will be the large image, but if there are two, the second will be the thumbnail. It's a big ugly mess.

So far I'm doing this:

my @images = ( [], [] ); my ( $img_1_str, $img_2_str) = split( '\|', $str); @{ @images[0] } = $img_1_str =~ m/(\w+\.jpg)/gi; @{ @images[1] } = $img_2_str =~ m/(\w+\.jpg)/gi;

Which I think is foolproof, but I feel it's ugly and not particularly Perlish. Any suggestions?