On 8/31/07, Ken Foskey <[EMAIL PROTECTED]> wrote: > On Fri, 2007-08-31 at 15:08 -0400, Hunter Barrington wrote: > > is there a type() function in perl? i need to be able to test the > > contents of an array and > > if (type($value)=='string' or type($value)=='int') {print "i win";} > > if( $value =~ m/^\d+$/ ) { > print "I am a number\n"; > } snip
You might also consider Scalar::Util's looks_like_number which exposes the function the interpreter uses to determine if a scalar is a number. use Scalar::Util qw(looks_like_number); if (looks_like_number($value)) { print "I am a number\n"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/