Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: returning arrays from a sub - how clever is Perl?

by mildside (Friar)
on Oct 22, 2003 at 00:26 UTC ( [id://301124]=note: print w/replies, xml ) Need Help??


in reply to returning arrays from a sub - how clever is Perl?

So from the replies I have so far, it seems that Perl is not clever enough to optimize this case. I think this optimization would have been quite easy to implement: since you know the context for the return value at the time of calling the sub, why return an array when you know a scalar is required?

Cheers!

Update: After a few more replies with some benchmarking evidence (thanks davido and revdiablo) it appears my original guess was correct and that Perl is clever after all. Phew! All is right with the world.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-03-29 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found