my $input = '9525429E'; if ( $input =~ /^([0-9]{7})([A-Z])$/ ) { my @digits = split //, $1; print "@digits, $2"; } else { print "invalid input"; }