petdance has asked for the wisdom of the Perl Monks concerning the following question:
I currently have a data structure where I have a bunch
of (roughly) key/value pairs. However, they are NOT hashable,
both because keys are not unique, and because order is important.
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 >
Back to
Seekers of Perl Wisdom