in reply to pack and unpack multiple arrays with one common repeat prefix
For this particular case, you don't need a rep count because the whole thing is very well behaved.
Is this strictly an educational exercise, or do you have more complex data structures to interrogate? If the data is chunked in a different way, Counting Repetitions solves your trouble with parentheses, but this only works in the context where you get to pick how things are packed.print join(',', unpack("C/C* v*", $testinput)), "\n";
my $testinput = pack('C/a* a* a*', (pack 'Cvs', 1, 3, -5), (pack 'Cvs', 2, 4, -6) ); print join(',', unpack("C/(Cvs)", $testinput)), "\n";
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: pack and unpack multiple arrays with one common repeat prefix
by hexcoder (Curate) on Jun 15, 2017 at 16:21 UTC | |
by kennethk (Abbot) on Jun 15, 2017 at 19:05 UTC | |
by hexcoder (Curate) on Jun 15, 2017 at 22:06 UTC | |
Re^2: pack and unpack multiple arrays with one common repeat prefix
by chacham (Prior) on Jun 15, 2017 at 21:09 UTC | |
by kennethk (Abbot) on Jun 15, 2017 at 22:22 UTC | |
by chacham (Prior) on Jun 15, 2017 at 22:43 UTC |
In Section
Seekers of Perl Wisdom