in reply to Spliting a log file into chunks and saving it into an array

Hi, use "undef $/".

#! c:/perl/bin/perl.exe use strict; undef $/; open (LST,"c:/test/show.txt")||die "$^E ; $!\n"; my $data = <LST>; #print "$data"; my @array = split(/\*+/, $data); print "$_\n" for (@array);

I think it will help you.

Regards,
Velusamy R.

Replies are listed 'Best First'.
Re^2: Spliting a log file into chunks and saving it into an array
by tbone1 (Monsignor) on Sep 15, 2005 at 13:33 UTC
    This will work, but a word of advice from someone bitten by it before: save off that $/ variable first!

    #! c:/perl/bin/perl.exe use strict; $tmp_eol=$/; undef $/; . . .
    That way, when you are done splitting the chunks, you can take each array element and split them along $/ as you normally would do so.

    --
    tbone1, YAPS (Yet Another Perl Schlub)
    And remember, if he succeeds, so what.
    - Chick McGee

      That's what local is for ;-)

      my $line = do { local $/; <LST>; };