in reply to truncate only a last blank line

#!/usr/bin/perl -w use strict; my ($myfile, @LINES); open $myfile, "file" or die "Unable to open file: $!\n"; push @LINES, $_ for (<$myfile>); #print "$_" for @LINES; chomp ($LINES[$#LINES-1]) if ( $LINES[$#LINES] =~ m/\s+/ ); #print "$_" for @LINES;
or
#!/usr/bin/perl my @file = qx/cat file/; chomp ($file[$#file]) if $file[$#file] =~ m/\s+/;

worked for me.
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson

Replies are listed 'Best First'.
Re^2: truncate only a last blank line
by tcf03 (Deacon) on Dec 30, 2005 at 03:18 UTC
    OT: I once had need to remove the first line from a file and did it with this shell script...
    # this once had a purpose... LINES=$(wc -l $1 | awk '{print $1}') tail -$(echo $LINES - 1 | bc -l) $1
    Ted
    --
    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
      --Ralph Waldo Emerson