in reply to about while() combine with ARGV

First off, you might want to use @ARGV == 2 and @ARGV == 3 instead of that nasty $#ARGV business. It's "cleaner" and it is easier to understand in my opinion.

Anyway, the problem is that you're not removing the elements from @ARGV, and so the while loop is trying to read them as files.

if (@ARGV == 2) { $result = ">" . pop(@ARGV); # removes element from @ARGV # ... } elsif (@ARGV == 3) { $result = ">" . pop(@ARGV); $name = pop(@ARGV); # ... }

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a (from-home) job
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: about while() combine with ARGV
by thor (Priest) on Feb 19, 2002 at 12:45 UTC
    I'm a big fan of using shift for taking command line arguments. This way, they get assingned in the order that they were passed in. Just one less thing to debug.

    thor
      Except that since the first element of @ARGV is the one he wants to keep, he'd have to then put it back somehow.

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a (from-home) job
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

        perhaps unshift? or maybe pop the arguments off in the first place... TMTOWTDI!

        ~Particle

Re: Re: about while() combine with ARGV
by gdnew (Acolyte) on Feb 19, 2002 at 10:10 UTC
    I never thought about that.
    Thanks..