in reply to Re: Llama ./tac stumper
in thread Llama ./tac stumper

Unless I'm badly confused, I'm pretty sure that foreach( @ARGV ){ <> } isn't doing what you want. <> in list context should open every file in @ARGV, read all the lines, and return them.
@ARGV=reverse @ARGV; print reverse <>;

Replies are listed 'Best First'.
Re^3: Llama ./tac stumper
by davido (Cardinal) on Jun 07, 2004 at 06:23 UTC
    My apologies on botching the 2nd solution. Here's an update:

    use strict; use warnings; my( @slurp ) = <>; @slurp = reverse @slurp; print @slurp;

    Dave

      You did actually verify if I was right didn't you?
        You did actually verify if I was right didn't you?

        @ARGV=reverse @ARGV; print reverse <>;

        I actually verified that both my <> solution and your solution are wrong (it does reverse the order of the lines of the files, but preserves original filename order). The idea is that a double-negative makes a positive.

        You were right that my solution had an error. You followed it up with a solution that also contained an error.

        I also verified that my final solution works properly. Hope the confusion is settled. ;)


        Dave