> From: "Joe Gottman" <[EMAIL PROTECTED]> > Date: Fri, 3 Jan 2003 22:25:16 -0500 > > > >>>>> "JG" == Joe Gottman <[EMAIL PROTECTED]> writes: > > > > JG> Speaking of which, is there a run-time test to check if a variable > is of > > JG> integral type? Something like > > > > JG> print "date" if ($var is int) && (1 <= $var <= 31); > > > > the old standby is: > > > > int( $var ) == $var > > > > I'm not sure if this works. > > my $var = "0"; # Notice the quotation marks > print "is integer" if (int($var) == $var); > > In the above case int($var) == $var returns true when I would want it to > return false.
print "date" if $var.isa(int); print "date" if isa $var: int; print "date" if $var ~~ int; Those should all work. IMO the first reads the best. That will also work for C<Int>s, as C<Int> is a subclass of C<int> (I think). Luke