[Chicago-talk] Limiting a hash, or producing an interesting list
Steven Lembark
lembark at wrkhors.com
Wed Nov 26 12:38:26 CST 2003
-- Jay Strauss <me at heyjay.com>
> I think my way:
>
> my @heading = someFunc();
> my (%all,%offset);
> my @interesting = qw/symbol expiration strike/;
> @all{@heading} = (0..$#heading);
> @offset{@interesting} = delete @all{@interesting};
>
> is better than your way:
>
> my @interesting = qw( what you knead );
> my @header = qw( what you get );
> my %fieldz = map { $header[$_] => $_ } ( 0..$#header );
> my @offsetz = grep { defined } @fieldz{@interesting};
> my %foo = ();
> @foo{@knead} = @input{@offsetz};
Why go to the effort of deleting the items from @all?
--
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 888 359 3508
More information about the Chicago-talk
mailing list