perl; getting a subset of hash keys based on a given value(s)
Ilya Palagin
tux-4CS0UopE6WdBDgjK7y7TUQ at public.gmane.org
Tue Mar 29 21:58:30 UTC 2005
Quoting Madison Kelly <linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org>:
..
>
> I am hoping there is a better way I could do the 'foreach ...'
> section to accomplish what I want. Before this I was creating the
> hash keys using '<dev_id>:<parent_dir>:<file_name>:<file_type>' and
> then using:
>
> foreach ( grep {/^$src_dirs[$i]\:.*[^d]$/} keys %src )
Looping through hundreds of thousands records won't be fast in perl.
Inserting
those records into a temporary table in a database will allow getting results
much faster.
>
> But that was taking over 2sec/dir. which meant my program would
> take up to 7h to run this one task. The great guys and gals at TPM
> helped me get my head around 'name => value' style hashes. So this
It's actually the only style of hash. The one you've been using before was a
hash with zero values.
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list