Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: RFC: Perl meta programming

by Sidhekin (Priest)
on Oct 19, 2006 at 21:44 UTC ( #579475=note: print w/replies, xml ) Need Help??


in reply to Re^2: RFC: Perl meta programming
in thread RFC: Perl meta programming

What's a better way to validate an array ref than "if( 'ARRAY' eq ref $foo )"? Thanks!

There are caveats whichever way you do it, but currently I tend to default to just derefing it within an eval block:

if (eval{ use strict 'refs'; @$foo; 1 }) { # it is, or pretends convincingly, to be an array ref }

Caveat? Right. In the presence of ties or overloading, there may be side effects to derefing it. Pick your poison / buyer beware / etc.

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2018-11-18 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (206 votes). Check out past polls.

    Notices?