jjap has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
Thanks for very very informative answers, and BrowserUK's suggested use of constant works really nicely! ++ too all!! Update2: enum mentioned later could be a fabulous time saver as well, but I could not find a way to use it with anything else than scalars.
Having settled this issue of unpacking the "records" part of a binary file, I now tackle its "header" (or part of its header).
($name, $onebyte, @twobytes, @fourbytes, $back2onebyte, @trailing) = unpack( "Z16 C1 C2 C4 C1 x400 C*", $data );
The @twobytes array swallows all remaining bytes of the file, not just the 2 is am seeking. The next variables remain of course undefined. Any hints on why that happens?
For a secondary question (once I can solve the first issue), I'll mention I have over 50 variables of varying size in that header. Am I on a valid approach by appending them in the above statement? That will end up being one looong statement...Again I am very thankful for any hints as well as for your indulgence in case I am missing the obvious
UpdateThanks for very very informative answers, and BrowserUK's suggested use of constant works really nicely! ++ too all!! Update2: enum mentioned later could be a fabulous time saver as well, but I could not find a way to use it with anything else than scalars.
Back to
Seekers of Perl Wisdom