in reply to Re: Deleting last line of file
in thread Deleting last line of file

I'm trying to run the shell command in my script, but for some reason, it's not working....can anyone pinpoint the problem? thanks
my @args = qw/ perl -i -ne 'print unless eof' filename /; system(@args) == 0 or die "error with deleting last line";

Replies are listed 'Best First'.
Re^3: Deleting last line of file
by flounder99 (Friar) on Aug 07, 2002 at 19:06 UTC
    I don't think you understand what qw does. Try running this and I think you will figure it out.
    my @args = qw/ perl -i -ne 'print unless eof' filename /; print join "|", @args;

    --

    flounder

Re: Re: Re: Deleting last line of file
by jmcnamara (Monsignor) on Aug 08, 2002 at 00:01 UTC

    That was just a one-liner.

    If you need to do something more sophisticated as part of a program you should try something like this.

    #!/usr/bin/perl -w use strict; # Localised in-place edit { local $^I = ''; # or use '.bak' to save a back-up local @ARGV = 'somefile'; while (<>) { print unless eof; } } __END__

    --
    John.