明らかにsubstr使うのがベストだろうけど。

$str = '200402';
$str =~ /^(\d{4})(\d{2})$/;
print $y = $1;
print $m = $2;