my $string = "P5"; my $num = substr $string, 1; # or my( $num ) = $string =~ m/^\w(\d+)/; # or my $num; $num = $1 if $string =~ m/^\w(\d+)/;