awohld has asked for the wisdom of the Perl Monks concerning the following question:
Where I create "@remapped_list" using the comma ( , ) seems natural and I understand its creating an anonymous array of two elements. But how does it work the same with the "=>" ? I thought the => was for creating anonymous hash references.#!/usr/bin/perl -w use strict; use Data::Dumper; my %items; $items{'joe'} = [ qw(pocket_knife coffee book hanker_chief) ]; $items{'sally'} = [ qw(eye_liner nail_polish purse) ]; $items{'bob'} = [ qw(calculator pocket_protector skittles ) ]; my @remapped_list = map { [ $_ => $items{$_} ]; } keys %items; print Dumper \@remapped_list; @remapped_list = map { [ $_, $items{$_} ]; } keys %items; print Dumper \@remapped_list;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: List Separator?
by shmem (Chancellor) on Nov 17, 2007 at 22:48 UTC | |
Re: List Separator?
by FunkyMonk (Chancellor) on Nov 17, 2007 at 22:46 UTC |