i'm changing some code which used to loop through the key/value pairs in a hash. Now the source table has three pieces of data per line, and I don't know what the while/for syntax is. It's important to keep the data triplets clear in the source, not make three lists. Here's what I'm trying to do - many thanks for any advice.
# originally had paired data
my %dynval = qw {
obVersion 0x0204
obStat 0x04b4
obMode 0x0020
obRegulation 0x0014
obScheduler 0x0001
<lots more data ...>
}
# simple, can do this
while((my $name, my $val) = each(%dynval)) {
set_value( $name, $val );
}
# new world with triplet data
# must keep the data line-by-line for easy viewing
my @dynval3 = qw (
Version obVersion 0x0204
Stat obStat 0x04b4
Mode obMode 0x0020
Regulation obRegulation 0x0014
Scheduler obScheduler 0x0001
)
while ?? for ?? (@dynval3)
change_value($newname, $name, $val);
}
should dynval3 be a list or is some other structure simpler?
thanks
alan
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.