On Mon, Dec 04, 2000 at 10:26:37PM -0700, Michael Eggleston wrote: > > I have a very large text file with about 90,000 lines in it. A vast > > majority of the lines are blank. (In case anyone is interested, it was > > created with the bookmanager print-to-file command) > > > > My question involves is this: When 3 (or "N") or more blank lines are > > found, delete them. Leaving 2 in their place, and possibly a marker. > > Here is a very simple way of doing it, however it might be a memory hog: > > open (TEXT, "MyFile.file"); ### This opesn up the file. > my @Lines = <TEXT>; ### This sticks it into an array. > close TEXT; ### This closes the file. Certainly, having two copies of the file will be more of a memory hog than having one: > $TheFile = join ('', @Lines); ### This makes that array into a scalar value. If you want to read the entire file into a scalar, then read it directly into a scalar: open(TEXT, $file) or die "Can't open $file: $!\n"; # check the return value from open()! { local $/; # file slurp mode $text = <TEXT>; } # ... Ronald # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org