Help for this page

Select Code to Download


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