Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: push to array without copying (\@_)

by tye (Sage)
on Nov 15, 2016 at 02:50 UTC ( #1175922=note: print w/replies, xml ) Need Help??


in reply to push to array without copying

There is one rather ugly trick for getting a reference to an array containing aliases:

my %hash = ( a => 1, b => 2, c => 3, d => 4 ); my $av = sub { \@_ }->( @hash{'d','b','c','a'} ); print "@$av\n";

But I'd likely go with BrowserUk's suggestion instead.

- tye        

Replies are listed 'Best First'.
Re^2: push to array without copying (\@_)
by LanX (Cardinal) on Nov 15, 2016 at 06:03 UTC
    > But I'd likely go with BrowserUk's suggestion instead

    True but since I can't find this "aliasing" documented in delete it has the disadvantage of an implementation detail.

    Though I don't expect it to be changed ever, since it's a safe performance gain.

    edit

    And more importantly the code wouldn't break if this was changed, only slow down.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2020-10-01 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (13 votes). Check out past polls.

    Notices?