petdance has asked for the wisdom of the Perl Monks concerning the following question:
Currently, I have lots of accessor functions where I do stuff like this to extract the values, but not the keys.
Any suggestions on a better idiom? I really don't dig having to make a copy of the list to jump thru it. I've thought about hitting the 2nd, 4th, 6th, etc elements, but that seems to non-Perl-like.my @subs; my @subdata = @{$self->{_subfields}}; while ( @subdata ) { my $code = shift @subdata; my $text = shift @subdata; push( @subs, $text ); } # for # And then I can do stuff with @subs
Suggestions welcomed...
Thanks,
xoxo,
Andy
%_=split/;/,".;;n;u;e;ot;t;her;c; ". # Andy Lester 'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'. # http://petdance.com "hack";print map delete$_{$_},split//,q< andy@petdance.com >
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Idiom for looping thru key/value pairs
by MeowChow (Vicar) on May 26, 2001 at 00:36 UTC | |
(tye)Re: Idiom for looping thru key/value pairs
by tye (Sage) on May 26, 2001 at 00:33 UTC | |
Re: Idiom for looping thru key/value pairs
by Masem (Monsignor) on May 26, 2001 at 00:40 UTC | |
by petdance (Parson) on May 26, 2001 at 01:09 UTC | |
by tye (Sage) on May 26, 2001 at 01:12 UTC | |
Re: Idiom for looping thru key/value pairs
by tinman (Curate) on May 26, 2001 at 00:36 UTC | |
by frag (Hermit) on May 26, 2001 at 02:15 UTC | |
(dkubb) Re: (2) Idiom for looping thru key/value pairs
by dkubb (Deacon) on May 27, 2001 at 07:19 UTC | |
Re: Idiom for looping thru key/value pairs
by runrig (Abbot) on May 26, 2001 at 00:33 UTC |