in reply to Removing files listed in another file

If you don't mind some extra error messages, you can save a few strokes:
$ perl -ne '`rm $ARGV $_`' <packlist_file>
This will repeatedly try to remove the packlist file, hence the error messages.

The following trick saves strokes over the original one-liner, and doesn't produce extra error messages. Of course, if you cannot remove a file, it still gives an error message. One can see this as a feature! ;-)

$ perl -nle '!`rm $ARGV`..`rm $_`' <packlist_file>
Note the .. in void context.

-- Abigail

Replies are listed 'Best First'.
Re: Re: Removing files listed in another file
by hasant (Initiate) on Jul 01, 2001 at 22:18 UTC
    You cheat. The error message comes from the rm system command. :-)

    Anyway, I believe the range operator is evaluated in scalar context since it returns a sequence number until the file is exhausted.

    s::a::n

      Anyway, I believe the range operator is evaluated in scalar context since it returns a sequence number until the file is exhausted.

      You got it backwards. Context isn't determined by what the expression evaluates to. Context is determined by what is done to the value of an expression. The value of .. is ignored, hence, .. is in void context. Regardless whether it pushed a return value on the stack that got discarded anyway.

      -- Abigail