- or download this
$a = 'string';
if (defined ($a <=> $a)) { print "Oops"; }
- or download this
package Foo;
...
my $x = new Foo(3);
my $z = (0+$x); # $x+0 also produces error
- or download this
use Scalar::Util 'looks_like_number';
...
print looks_like_number($a), "\n";
print looks_like_number($h), "\n";
- or download this
sub _numberlike {
return 1, unless defined $_[0];
...
};
return;
}
- or download this
sub _stringlike {
return 1 unless defined $_[0] && ref $_[0];
...
};
return;
}