my( $fh, $start, $end, $n ) = @_; // $n is this process' sequence number seek $fh, $start, 0; <$fh>; // discard first read my $pos = tell $fh; while( $pos < $end ) { my $line = <$fh>; $pos = tell $fh; for my $regex ( @regex ) { $line =~ $regex; } ## write out modifed line. (see below) } #### my( $fh, $start, $end, $n ) = @_; // $n is this process' sequence number my @ranges = ( [ $start, $end/2-1 ], [ $end/2, $end] ); // a loop and careful math for more than 2 chunks for my $range ( @ranges ) { my( $start, $end ) = @$range; // use different names if you prefer seek $fh, $start, 0; <$fh>, $start = tell( $fh ) if $start != 0; // discard partial and get real starting point (if not beginning) seek $fh, $end, 0; <$fh>, $end = tell $fh; // get true end point; seek $fh, $start, 0; read( $fh, my $buffer, $end - $start +1; for my $regex ( @regex ) { $buffer =~ $regex; } ## write out modifed line. (see below) }