gyre007 has asked for the wisdom of the Perl Monks concerning the following question:
What I don't understand is why the size of the array is not equal to the number of templates in template string passed to unpack function but it is still 71 items big as it is the size of the read block(BLOCK_SIZE = 71). I thought unpack works the way as I wrote it, but I was terribly wrong... Can anyone help me with this ? Otherwise I will just have to use substr functions to cut the buffer into such long parts I need ? Thanks!open INF, $FileName or die "\nCan't open $FileName for reading: $!\n"; binmode INF; while ( ($readBytes = read (INF, $buffer, BLOCK_SIZE )) ){ print 'Read bytes:'.$readBytes."\n"; $BlockCounter++; @data = unpack('C C C C C C C C C C3 C3 C5 C5 C3 C3 C3 C C3 C C12 +C20', $buffer); $tmp = @data; print "Size of DataArray = $tmp\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why the unpack doesnt split the data to the array ?
by ikegami (Patriarch) on Aug 06, 2008 at 19:00 UTC | |
by gyre007 (Novice) on Aug 06, 2008 at 19:10 UTC | |
by Corion (Patriarch) on Aug 06, 2008 at 19:14 UTC | |
by gyre007 (Novice) on Aug 06, 2008 at 19:20 UTC | |
by ikegami (Patriarch) on Aug 06, 2008 at 19:24 UTC | |
by ikegami (Patriarch) on Aug 06, 2008 at 19:21 UTC |