in reply to Clarity in parsing fixed length data.
Update: As pointed out below, this doesn't work! Sorry, A rush of blood I think.
If you used a hash to contain your spec:
my %TEST_REC_PACK_FLDS = { status => 'n ', # 0 time => 'n ', # 2 date => 'N ', # 4 code => 'a16', # 8 key msid => 'a10', # 24 key };
Then your field names becomes just
use constant @TEST_FLDS => keys %TEST_REC_PACK_FLDS;
and you build your format string using
use constant TEST_REC_PACK => $join ' ', values %TEST_REC_PACK_FLDS;
You might want to uppercase the field names.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Clarity in parsing fixed length data.
by runrig (Abbot) on Aug 10, 2006 at 22:12 UTC | |
|
Re^2: Clarity in parsing fixed length data.
by ikegami (Patriarch) on Aug 10, 2006 at 22:12 UTC | |
|
Re^2: Clarity in parsing fixed length data.
by rodion (Chaplain) on Aug 10, 2006 at 22:18 UTC |