Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Removing the first record in a file containing fixed records

by Crackers2 (Parson)
on Jul 18, 2008 at 00:48 UTC ( [id://698486]=note: print w/replies, xml ) Need Help??


in reply to Re: Removing the first record in a file containing fixed records
in thread Removing the first record in a file containing fixed records

If ordering is not important he could just read the very last record, overwrite the first record with it and truncate the file before the last record.
  • Comment on Re^2: Removing the first record in a file containing fixed records

Replies are listed 'Best First'.
Re^3: Removing the first record in a file containing fixed records
by Perlbotics (Archbishop) on Jul 18, 2008 at 09:08 UTC
    Since sparkle asked for an efficient method that works even on large files (2GB is sometimes the next limit), I agree with Crackers2 suggestion that will work well since it preserves disk space and implies a minimal amount of copy operations. But in case the header has a different size than the other records, order is important, or in case a copy of the file is still required, I would suggest to give that task away to a tool that is optimised for that kind of operations. Where available, a system(...)-call to tail or dd might be worth consideration.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://698486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-24 01:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found