entropy has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (references)
I can take a slice of an array ref, but not of a hash ref:
The first print statement works, the second is a syntax error. I also have this problem when taking a slice of an anonymous hash:my $arr =[1,'a',2,'b']; my $hash={1,'a',2,'b'}; print join ':',(@$arr )[1,2]; print join ':',(@$hash){1,2};
Again, the first statement works, but the second is a syntax error.print join ':',(1,'a',2,'b')[1,2]; print join ':',(1,'a',2,'b'){1,2};
Originally posted as a Categorized Question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I take a slice of a hash reference?⭐
by japhy (Canon) on May 15, 2001 at 03:36 UTC | |
Re: How do I take a slice of a hash reference?
by dkubb (Deacon) on May 15, 2001 at 09:18 UTC | |
Re: How do I take a slice of a hash reference?
by tianping (Initiate) on Jun 02, 2011 at 08:40 UTC | |
Re: How do I take a slice of a hash reference?
by tachyon (Chancellor) on May 21, 2001 at 09:44 UTC | |
by tachyon (Chancellor) on May 21, 2001 at 10:00 UTC |
Back to
Seekers of Perl Wisdom