in reply to Parse messy string into neat data structure
becausemy @images = ( [], [] ); { my( @imgstr ) = split /\|/, $str, 2; @{ $images[0] } = $imgstr[0] =~ m/(\w+\.jpg)/gi; @{ $images[1] } = $imgstr[1] =~ m/(\w+\.jpg)/gi; }
or actuallymy @images; { my @imgstr = split /\|/, $str, 2; push @images, [ $_ =~ m/(\w+\.jpg)/gi ] for @imgstr; }
Yes, the last one is how I would normally write something like that, its funny how digesting someone else s code plays tricks on you :)my @images = map { [ $_ =~ m/(\w+\.jpg)/gi ] } split /\|/, $str;
|
|---|