Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: sub returning undef

by Abigail-II (Bishop)
on May 24, 2004 at 16:10 UTC ( [id://355957]=note: print w/replies, xml ) Need Help??


in reply to Re: sub returning undef
in thread sub returning undef

A sub never returns an array _directly_, but it can return arrays by reference, along with anything else it wants to return, in its list of return values.
Well, duh. That's like responding to someone who says "you can't make trees with a camera, just pictures" with "but you can make a picture of a tree!".

The whole problem of the OP deals with the fact subs return lists, not arrays. The fact that a list element can be a reference to an array is an interesting observation in its own right - but not for this discussion.

The OP may have meant that the sub returns a list of whatevers, or he might have meant that it returns an array reference.
The code never uses references. Both the comment and the code show that the OP expected @array to be empty. It's pretty clear to me what the OP expected, and where the OP went wrong.

Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found