in reply to Defining an anonymous hash with slices and lists.

Never say "no way". But the question would be, "why?".
my $number = 2; my $word = ${my %x; @x{qw(1 2 3)} = qw(one two three); \%x}{$number};

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Defining an anonymous hash with slices and lists.
by Anonymous Monk on Aug 27, 2003 at 22:04 UTC
    my %x is not anonymous
Re: •Re: Defining an anonymous hash with slices and lists.
by davido (Cardinal) on Aug 28, 2003 at 16:41 UTC
    I liked merlyn's example so much that I put it to work somewhere (because it can be done, not because this construct is clear or pretty).

    By the way, his answer reversed my original hash, but the idea was good, and its implication clear.

    To see it in action in a fully functional NATO Phonetic Alphabet Translator see this link. It's an impractical application, and this method isn't the "best way to do it", but it's an example of putting this method to work.

    Enjoy!

    Dave

    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein