#!/usr/bin/perl use strict; use warnings; my $in_qfn = '...'; my $out_qfn = '...'; open( my $in_fh, "<:raw", $in_qfn ) or die( "Can't open `$in_qfn`: $!\n" ); open( my $out_fh, ">:raw", $out_qfn ) or die( "Can't create`$out_qfn `: $!\n" ); my $int_size = 4; # length( pack( "L<", 0 ) ); local $/ = \( 8 * 1024 ); while ( my $in_buf = <$in_fh> ) { length( $in_buf ) % $int_size == 0 or die( "Invalid input file `$in_qfn`\n" ); my @ints = unpack( "L<*", $in_buf ); # Something that modifies `@ints` here. print( $out_fh pack( "L<*", @ints ) ) or die( "Error writing to `$out_qfn`: $!\n" ); } close( $in_fh ) or die( "Error reading from `$in_qfn`: $!\n" ); close( $out_fh ) or die( "Error writing to `$out_qfn`: $!\n" );