use strict; use warnings; my $str = '*E2@x*PAP'; if ($str =~ /\*(.+?)\@x\*(.+?)$/) { print "1st: $1\n"; print "2nd: $2\n"; } __END__ 1st: E2 2nd: PAP