Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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
Node Status?
node history
Node Type: note [id://160812]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2018-07-17 13:53 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (368 votes). Check out past polls.