# +ve int, not inc zero, optional space, optional sign $var1 =~ s/^\s+//; # leading whitespace $var1 =~ s/\s+$//; # trailing whitespace if( $var1 =~ /^[+]?\d+$/ && $var1 != 0 ) { print "+ve int\n"; }