Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^3: Quick Question - Append File at Beginning?

by BillKSmith (Priest)
on Nov 16, 2013 at 13:58 UTC ( #1062894=note: print w/replies, xml ) Need Help??

in reply to Re^2: Quick Question - Append File at Beginning?
in thread Quick Question - Append File at Beginning?

I believe that the relavent FAQ is much easier to find with the tool perldoc.

perldoc -q "append to the beginning of a file"

Replies are listed 'Best First'.
Re^4: Quick Question - Append File at Beginning?
by taint (Chaplain) on Nov 16, 2013 at 21:23 UTC

    How does *NIX MBOX deal with data? Would the way it does it, offer some interesting methods.

    Just a thought.


    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;
      How does *NIX MBOX deal with data? Would the way it does it, offer some interesting methods.

      Are you refering to "the" mbox mail box file format? (See Wikipedia,, Jonathan de Boyne Pollard, RFC 4155)

      Well, actually, there are serveral slightly incompatible formats, and they all are essentially append-only formats. A variant is used by Netscape's Communicator and its derivates (Thunderbird, Seamonkey). It has a separate index file containing the file offsets of the e-mails in the mbox file and some other data. "Compacting" the mailbox just rewrites the entire mbox file, omitting all e-mails flagged as deleted. (See Mail servers using the mbox format probably do something similar. I remember one old server at my university that kept a special first message in the mbox files, invisible via POP3 and IMAP. Parts of this message were constantly overwritten to keep track of changes to the mbox file. I think that some of my old linux machines behaved the same until I've switched to imapdir several years ago.

      So, perhaps the only useful ideas from mbox are a second file containing a list of file offsets into the main file, and a special (fixed size) directory record at the beginning of the main file.


      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        Right you are afoken.

        My bad. I'm afraid I had an incorrect association in my head. I had viewed a couple of mailboxes in the past, and somehow remembered that new entries were pushed to the top of the stack. I imagine my *incorrect* recollection stems from the fact, my reader sorts the order *reversed*.

        Thanks for the correction, afoken.

        Next time, I'll take the time to confirm my thoughts before posting them. :P


        #!/usr/bin/perl -Tw
        use Perl::Always or die;
        my $perl_version = (5.12.5);
        print $perl_version;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062894]
[Corion]: marto: Yeah - there isn't a Perl Day-Care at Perl events - we thought about it for YAPC::Europe 2012 but it's a gigantic effort to organize that
[marto]: Corion yeah, it'd be too costly for me to bring them both :P

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2016-12-07 09:33 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (125 votes). Check out past polls.