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.
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
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.
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 >
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.