replaces "associative array" with "hash"
clears aggregates with "= ()" rather than undef-ing them. Index: perlfaq4.pod =================================================================== RCS file: /cvs/public/perlfaq/perlfaq4.pod,v retrieving revision 1.15 diff -u -d -r1.15 perlfaq4.pod --- perlfaq4.pod 21 Feb 2002 14:48:01 -0000 1.15 +++ perlfaq4.pod 21 Feb 2002 14:53:37 -0000 @@ -1,6 +1,6 @@ =head1 NAME -perlfaq4 - Data Manipulation ($Revision: 1.15 $, $Date: 2002/02/21 14:48:01 $) +perlfaq4 - Data Manipulation ($Revision: 1.14 $, $Date: 2002/02/08 22:30:23 $) =head1 DESCRIPTION @@ -1130,11 +1130,11 @@ That being said, there are several ways to approach this. If you are going to make this query many times over arbitrary string values, -the fastest way is probably to invert the original array and keep an -associative array lying about whose keys are the first array's values. +the fastest way is probably to invert the original array and maintain a +hash whose keys are the first array's values. @blues = qw/azure cerulean teal turquoise lapis-lazuli/; - undef %is_blue; + %is_blue = (); for (@blues) { $is_blue{$_} = 1 } Now you can check whether $is_blue{$some_color}. It might have been a @@ -1144,7 +1144,7 @@ array. This kind of an array will take up less space: @primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31); - undef @is_tiny_prime; + @is_tiny_prime = (); for (@primes) { $is_tiny_prime[$_] = 1 } # or simply @istiny_prime[@primes] = (1) x @primes;