in reply to variable type

If you are unsure about weather something is an integer or not, you can always multiply it by 1 to force it into integer context. Be careful since this is dangerous as you are forcing data to change. For example:
use strict; use warnings; my $x = <STDIN>; $x *= 1; print "String\n" if ($x =~ /\w/); print "Integer\n" if ($x =~ /\d/); print $x**$x ."\n"; __OUTPUT__ e Argument "e\n" isn't numeric in multiplication (*) at tmp.pl line 8, < +STDIN> line 1. String Integer 1

Now consider the following code (use lines removed for brevity):

my $x = <STDIN>; print "String\n" if ($x =~ /\w/); print "Integer\n" if ($x =~ /\d/); print $x**$x ."\n"; __OUTPUT__ e String Argument "e\n" isn't numeric in exponentiation (**) at tmp.pl line 13, + <STDIN> line 1. 1

Lastly, consider this piece of code forcing the string or integer into integer context. Notice the exponentiation doesn't throw an error because the input was forced into integer context.

my $x = <STDIN>; $x *= 1; print "String\n" if ($x =~ /\w/); print "Integer\n" if ($x =~ /\d/); print $x**$x ."\n"; __OUTPUT__ 2 String Integer 4

Note: The reason its a string and an integer is in the case of \w (which is what the regex uses), it checks for [0-9a-zA-Z] as well.