[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Weird... I'm voluntarily using map



Huh... I'm starting to get pretty comfortable w/ map... Old dog, new
tricks. :)

j


# Given this array ref:
my $j = [ "a", "b", "c" ];

# Make a hash so we can do key-based lookups:
my %j = map { $_ => 1 } @$j;



---------

$ perl -d -e '1'

Loading DB routines from perl5db.pl version 1.28
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   1
auto(-1)  DB<1> o pager=less
               pager = '|less'
  DB<2> $j = [ "a", "b", "c" ];

  DB<3> %j = map { $_ => 1 } @$j;

  DB<4> x %j
0  'c'
1  1
2  'a'
3  1
4  'b'
5  1