in reply to New Line at End File
Here's a way to do it without reading the whole file in first...
#!/usr/bin/perl use strict; use Fcntl qw(SEEK_END SEEK_CUR); my $f = shift; open F, "+<", $f or die "Couldn't open $f: $!\n"; seek F, -1, SEEK_END; seek F, -2, SEEK_CUR while (getc(F) eq "\n"); truncate F, tell F;
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: New Line at End File
by BrowserUk (Patriarch) on Dec 10, 2002 at 05:10 UTC | |
by sauoq (Abbot) on Dec 10, 2002 at 19:58 UTC | |
|
Re: Re: New Line at End File
by jmcnamara (Monsignor) on Dec 10, 2002 at 11:29 UTC | |
by sauoq (Abbot) on Dec 10, 2002 at 19:55 UTC | |
by jmcnamara (Monsignor) on Dec 11, 2002 at 08:38 UTC |