>>>>> "BRH" == Bryan R Harris <[email protected]> writes:
BRH> Just as an academic exercise, I thought I should be able to do this:
BRH> **************************************
BRH> @a=(l=>35,k=>31,r=>7,k=>6);
BRH> @r=qw/l r r k/;
try to use some white space in your code. even in short examples it
helps.
BRH> # make an anonymous hash using @a, then grab values from it using
BRH> @r as keys
BRH> @a...@a}{@r};
learn the first rule of dereferencing. take a reference and wrap it in
{} with the proper sigil prefix. so to deref a hash, wrap it in %{}.
so you are making an anon hash around @a but not dereferencing it. you
need %...@a}}.
then to take a slice of that, you would change the % to @:
@{...@a}}{@r}
BRH> ... but it doesn't like the {}{} notation. Is this not possible?
BRH> I do this with lists all the time, e.g. @a = (split)[1,7,15];
that isn't the same. that is a slice of a list. you had an anon hash
which must be dereferenced first before you can slice it.
uri
--
Uri Guttman ------ [email protected] -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/