my $str = "123e4"; print asNum( $str ); sub asNum { my $str = shift; my $foo; eval "\$foo = $str"; # backslash for string not reference if( $@ ) { warn( "oops : $@" ); } return $str; }