[Omaha.pm] map: make a hash from an array
Jay Hannah
jhannah at omnihotels.com
Wed Sep 14 07:46:28 PDT 2005
Given an array:
my @keepthese = qw(
account_code adult_qty arrival_date child_qty depart_date gds_sys
group_code lang_code prop prune_level rate_code rate_type room_type
seamless_bk_code sga
);
Here's the slow way to make a hash out of it:
my %keepthese;
foreach (@keepthese) {
$keepthese{$_} = 1;
}
Here's a faster way:
my %keepthese = map { $_, 1 } @keepthese;
HTH,
j
More information about the Omaha-pm
mailing list