You need SymRefs. Somthing like :
$tmp =~ m/(.+)(\d+)$/;
${$1} = $2;
But, There are great many nodes in
Super Search which i suggest reading, as this is usually a poor coding practice. If you read the nodes, and feel this is still needed, then the above would be the way to do it.
$ perl -e 'do() || ! do() ;'
Undefined subroutine &main::try