in reply to Getting element of array with a match
As a better solution for this problem, consider using a hash instead of an array to store your data (that is, if the first field in your data is unique). Hashes are built for fast text searches:print (split /,/,$_)[1] for grep /^1006/, @array; #UNTESTED
use strict; my %hash=qw(1001 choochoo 1002 candycane 1003 sockpuppet); print $hash{'1003'}; __END__ sockpuppet
CU
Robartes-
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Getting element of array with a match
by broquaint (Abbot) on Dec 23, 2002 at 15:19 UTC | |
by peppiv (Curate) on Dec 23, 2002 at 16:04 UTC |