Mnementh has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks,

I wondering if this operation is possible or not :

I've got a large journal file (2Gb) written every time, one per day.

The data are written in hexa, so I can read them with an unpack() command.

The file is composed of one gigantic line which add new record at the end every seconds.

My goal is to parse data from this journal, but I didn't find any method that allows a tail or something else on a binary file.

Does someone have a trick for that ?

Regards,

Mnementh

Replies are listed 'Best First'.
Re: Parsing binary file during update
by Corion (Patriarch) on Feb 01, 2017 at 14:40 UTC

    See the documentation on seek, which has an example of how to "tail" a file:

    for (;;) { for ($curpos = tell($fh); $_ = readline($fh); $curpos = tell($fh)) { # search for some stuff and put it into files } sleep($for_a_while); seek($fh, $curpos, 0); }

    You will either set $/ to your record size so that readline does its magic or simply read your records yourself instead of using readline.

Re: Parsing binary file during update
by Mr. Muskrat (Canon) on Feb 01, 2017 at 18:00 UTC

    You may be reinventing the wheel. What kind of journal file is it? Have you searched for a Perl module that reads that file type?