my @images; { my @imgstr = split /\|/, $str, 2; push @images, [ $_ =~ m/(\w+\.jpg)/gi ] for @imgstr; }