Okay, knowing that the bit patterns are byte aligned and the records are 384 bytes each makes thing much easier. The following program should do the trick quite efficiently.

#! perl -slw use strict; use bytes; ## Force byte semantic rather than (unicode) character sema +ntics. ## 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 discar +ded. while( <IN> ) { print OUT unpack 'x2 A190 x2 A58', $_; } close IN; close OUT;

In theory, the following 'one-liner' (I've wrapped it to save PM the bother) would also work.

If you have the time/patience/enthusiasm to try it, I'd love to know if it does.

You will have to twiddle the "s -v- 's issue if you're on a non-Win32 platform.

perl -C0 -mbytes -e"BEGIN{$/=\384}" -ne"print unpack 'x2 A190 x2 A58', $_" <infile >outfile

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re^5: Out of memory problems by BrowserUk
in thread Out of memory problems by tperdue

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.