in reply to Re: matching everything between over two lines
in thread matching everything between over two lines

I gave that a go with the following, as i am passing the file in from the command line.
open(FG,"$ARGV[0]") || die &writelog(1,"INFO: processfile_rt: Unable t +o open log file: $!"); my $str = <FG>; while($str =~ /Message dump:((?:(?!Message dump:).)*)/gs) { print "$1\n"; }
But that does not seem to print out anything.

file is
Message dump: 460 05/12/21 11:41:18:000 Sent FIX Message Message dump: 461 05/12/21 11:41:23:593 Received FIX message Message dump: 462 05/12/21 11:41:48:093 Sent FIX Message Message dump: 463 05/12/21 11:41:55:625 Received FIX message Message dump: 464 05/12/21 11:42:18:015 Sent FIX Message Message dump: 465 05/12/21 11:42:27:531 Received FIX message Message dump:

Replies are listed 'Best First'.
Re^3: matching everything between over two lines
by Corion (Patriarch) on Feb 23, 2006 at 10:28 UTC

    You are reading the file line by line, but try matching across lines in your regular expression. That can't work. Either read the whole file into memory and then try the while loop or set the Record Separator $/ to Message dump:, or use the .. operator:

    while (<>) { print if ! /^Message dump:$/) };
Re^3: matching everything between over two lines
by Sec (Monk) on Feb 23, 2006 at 10:29 UTC
    your code appears to only read the first line of the file. Try my $str=join("",<FG>); instead of the second line.