Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
go ahead... be a heretic
 
PerlMonks  

Re: How do I take a slice of a hash reference?

by tachyon (Chancellor)
on May 21, 2001 at 05:44 UTC ( [id://81919]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to How do I take a slice of a hash reference?

All that is wrong with your code is the parenths. Join takes a list ie: join '', (list); To give list context to your hash slice all we need to do is move the parenths as shown, this runs fine.

Note that we do not need parenths for the array at all.

my $arr = [1,'a',2,'b']; my $hash = {1,'a',2,'b'}; print join ':', @$arr[1,2]; print join ':',(@$hash{1,2});

tachyon

Replies are listed 'Best First'.
Re: Answer: How do I take a slice of a hash reference?
by tachyon (Chancellor) on May 21, 2001 at 06:00 UTC

    Wrong button, especially with a missing </code> Scorn pours forth like a raging torrent....

    All that is wrong with your code is the parenths. Join takes a list ie: join '', (list); To give list context to your hash slice all we need to do is move the parenths as shown, this runs fine.

    my $arr = 1,'a',2,'b'; my $hash= {1,'a',2,'b'}; print join ':', @$arr1,2; print join ':',(@$hash{1,2});

    Note that we do not need parenths for the array at all.

    tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://81919]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.