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

Re^3: push to a referenced array

by jasonk (Parson)
on Sep 28, 2008 at 14:15 UTC ( #714172=note: print w/ replies, xml ) Need Help??


in reply to Re^2: push to a referenced array
in thread push to a referenced array

Hiding implentation details by writing tiny functions instead of just using references the way everybody else does rarely makes code cleaner. This is doubly true when the function you replace it with is obfuscated.

If you really need a golf function to do it though, it can be made shorter...

sub ref_push{push@{$_[0]||=[]},@_[1..$#_]}

www.jasonkohles.com
We're not surrounded, we're in a target-rich environment!


Comment on Re^3: push to a referenced array
Download Code
Replies are listed 'Best First'.
Re^4: push to a referenced array
by biga (Sexton) on Sep 28, 2008 at 17:42 UTC
    Thank you for advice, guys. You've helped me a lot. %)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2015-08-31 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (352 votes), past polls