use warnings;
use strict;
my $str = '1234567890';
my @unpacked = unpack 'A1 x2 A1 X2 A1', $str;
print "@unpacked";
Prints:
1 4 3
A1 gets the first character (1), x2 skips two (23), A1 gets one character (4), X2 backs up two characters (43), A1 gets one character (3).
BTW print "@unpacked"; prints the elements in @unpacked with spaces between them as print join ' ', @unpacked; would.
DWIM is Perl's answer to Gödel
|