in reply to grepping
{ my %data; @data{@data} = 1; # turn @data into a lookup hash foreach ( @data2 ) { print "This $_ was not found.\n" if not exists $data{$_} } }
Update: An aside with MeowChow has convinced me that @data{@data} = undef; # turn @data into a lookup hash is less misleading. As with the "= 1" form above, only the value for the first key is set, and all remaining values are set to undef. Since we're just using the hash as a way to trade time for space in detecting the presense of keys, values don't matter. But the originally was slightly misleading nonetheless.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: grepping
by MeowChow (Vicar) on Mar 25, 2001 at 01:10 UTC | |
Re: Re: grepping
by Anonymous Monk on Mar 25, 2001 at 11:15 UTC | |
by dws (Chancellor) on Mar 25, 2001 at 11:21 UTC | |
by Anonymous Monk on Mar 25, 2001 at 11:31 UTC | |
by dws (Chancellor) on Mar 25, 2001 at 11:37 UTC | |
by Anonymous Monk on Mar 25, 2001 at 12:36 UTC | |
|
In Section
Seekers of Perl Wisdom