Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: undef'ing @arrays caveat

by vladb (Vicar)
on Apr 20, 2002 at 21:56 UTC ( #160812=note: print w/replies, xml ) Need Help??

in reply to undef'ing @arrays caveat

Actually Juerd is right as far as my code goes.. In one of my scripts i have a subroutine which at the end does this:
sub a_sub { my @things; . . . return ($should_return_stuff) ? @things : (); }
In previous version of the code, I overlooked this part and had 'undef' in place of the pair of brackets '()' (for empty array). Since I have to do this conditional in the return statement, I can't simply have a return; statement all by itself (well, i could... but not without having to add an extra line of code). I somehow assumed that returning 'undef' would make things work. Certainly, I'm a new man now.. clean of the indispicable sin of the past *grin*.

Thanks you all for good points/comments. My initial post was in fact meant to dispose the kind of stupidity that other monks (ak'a myself) get into from time to time. Also, I hoped the post could help a rare few monks who could otherwise fall in the same trap that I did... no big issue, though. ;-)

"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2023-09-21 21:33 GMT
Find Nodes?
    Voting Booth?

    No recent polls found