I know this will work on Linux but I'm pretty sure that it won't work on Windows:
my $filename = 'somefile'; my $rec_len = 567; open my $IN, '<:raw', $filename or die "Cannot open '$filename' $!"; open my $OUT, '+<:raw', $filename or die "Cannot open '$filename' $!"; my $file_size = -s $IN; my $total_records = $file_size / $rec_len; $/ = \$rec_len; while ( <$IN> ) { next if $. == 1; print $OUT $_; } $total_records == $. or die "Read only $. records but expected $total_ +records records!\n"; truncate $IN, $file_size - $rec_len; close $OUT; close $IN;
Or you could do it using one of the memory mapped file modules which should work on windows.
In reply to Re: Removing the first record in a file containing fixed records
by jwkrahn
in thread Removing the first record in a file containing fixed records
by sparkle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |