#! perl -slw use strict; use bytes; ## Force byte semantic rather than (unicode) character semantics. ## Maybe unnecessary, but it won't hurt. ## Using ':raw' is (roughly) equivalent to using [binmode] open IN, '< :raw', $ARGV[ 0 ] or die "$ARGV[ 0 ] : $!"; open OUT, '> :raw', $ARGV[ 1 ] or die "$ARGV[ 1 ] : $!"; local $/ = \384; ## Read file in 384 byte chunks. ## The only magic here is that ## a) we are reading the file in 384 byte chunks ## b) The unpack format extracts just the bits we wish to retain ## from the exact offsets we need. ## x2 - skips the xF4 x?? bytes ## A190 - returns the 190 bytes we need to retain ## x2 - skips the second xF4 x?? bytes ## A58 - returns the next 58 bytes. ## - the remaining 132 bytes from the buffer are discarded. while( ) { print OUT unpack 'x2 A190 x2 A58', $_; } close IN; close OUT; #### perl -C0 -mbytes -e"BEGIN{$/=\384}" -ne"print unpack 'x2 A190 x2 A58', $_" outfile