Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Object::InsideOut field type validation

by gone2015 (Deacon)
on Feb 05, 2009 at 20:51 UTC ( [id://741689]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Object::InsideOut field type validation
in thread Object::InsideOut field type validation

I don't get it :-( I tried:

use strict ; use warnings ; try() ; # none: 1 try(undef) ; # undef: 1 try(-1) ; # -1: 0 try(0) ; # 0: 0 try(1) ; # 1: 1 sub try { my ($s) = @_ ; my $r = validate_max_size(@_) ; if (@_ == 0) { $s = "none" ; } elsif (!defined($s)) { $s = "undef" ; } ; printf "%8s: %d\n", $s, $r+0 ; } ; sub validate_max_size { my $val = shift; ! defined $val || $val > 0; }
on perl 5.10.0, and got no warnings...

I don't know if there's an ointment for bracket-alergy as extreme as this... I would write:

!defined($val) || ($val > 0) ;
'cos I'm comfortable with unaries binding tighter than binaries... but the effect is the same as what you writ.

Wait a tick... this gives the error you mentioned:

try('undef') ; # Argument "undef" isn't numeric in numeric gt (>) . +..
could it be that somebody, somewhere, is mapping undef to 'undef' ?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://741689]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found