my $line = "xx556xx"; my @list = $line =~ m/((??{ $a = substr( $line, pos($line), 1); $a ? quotemeta($a) . '+' : '$' }))/g; print "@list";