RBBD has asked for the wisdom of the Perl Monks concerning the following question:
The following splits on blank lines, but they are lost.
How do I keep them in the output?#!/usr/bin/perl #<"Grep.pl"> Grep Profile Info File undef $/; $INFOFILE="/admin/users/diebelr/llProfile.out"; open (IFILE, "$INFOFILE") || die ("Cannot open $INFOFILE\n"); @finfo=split(/\n{2,}/, <IFILE>); #<+++++ $tRecsInfo = @finfo; print "$tRecsInfo"; print "I read ", scalar(@finfo), " RECORDS\n"; @MATCHING = (); @MATCHING = grep(/\b@ARGV[0]\b/, @finfo); $MATCHED = @MATCHING; print "@MATCHING"; print "\n$MATCHED Entries Matched\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split on Blank Line into array, and keep the blank line in the array
by johngg (Canon) on May 22, 2009 at 23:15 UTC | |
by RBBD (Initiate) on May 23, 2009 at 00:09 UTC | |
by johngg (Canon) on May 23, 2009 at 10:28 UTC | |
|
Re: Split on Blank Line into array, and keep the blank line in the array
by linuxer (Curate) on May 22, 2009 at 22:15 UTC | |
|
Re: Split on Blank Line into array, and keep the blank line in the array
by ig (Vicar) on May 23, 2009 at 04:58 UTC |