http://qs321.pair.com?node_id=1212377


in reply to Re: Splitting a large file into smaller files according to indexes
in thread Splitting a large file into smaller files according to indexes

Works like a charm, thank you. How do I upvote this answer, sorry I am a newbie to perlmonks :)
Also, why do we initialize, $current_index as -1?

  • Comment on Re^2: Splitting a large file into smaller files according to indexes

Replies are listed 'Best First'.
Re^3: Splitting a large file into smaller files according to indexes
by hippo (Bishop) on Apr 05, 2018 at 20:48 UTC

      The tips say that I will see a radio button on the replies, but I cannot see any. Probably the case that I don't yet have the voting rights

        Probably ... I don't yet have the voting rights

        No, not as an Initiate, not until you become a Novice. Please see "What levels are there and how many votes do they get?" in Voting/Experience System.


        Give a man a fish:  <%-{-{-{-<

      The tips say that I have to look for radio button on the replies, but I cannot see any. So probably must be the case that I don't yet have the power to vote.

Re^3: Splitting a large file into smaller files according to indexes
by bliako (Monsignor) on Apr 05, 2018 at 23:32 UTC

    it is initialised to -1 (or whaterver other value your mrule number will not take) in order to force the opening of the file upon seeing the mrule pattern for the first time.

    Glad it worked (it's Perl after all) but I stress that it is untested by me for more complex cases.

    bliako

      As an example of where the above program may go wrong, consider what happens if mrule=140 appears in two different parts of your log file - NOT consecutively, i.e. another mrule line is in between. The last time's contents will overwrite the first time's contents!

      bliako