in reply to Invalid argument

It looks like you're using a global to pass arguments into handlefix. But the global you decided to use is @_, and Perl's subroutine calling mechanism also uses @_ to pass arguments, so those "global" values are not seen inside the sub. Why not use a normal method of passing arguments to a sub?
my $infile = !@ARGV?<>:shift @ARGV; my $outfile = !@ARGV?<>:shift @ARGV; handlefix($infile, $outfile);
You don't even have to change handlefix.

Might I also suggest to rewrite conditionals to avoid having a negative condition? For example, $infile = @ARGV ? shift @ARGV : <>

blokhead

Replies are listed 'Best First'.
Re^2: Invalid argument
by Andrew_Levenson (Hermit) on Dec 01, 2006 at 20:34 UTC
    Whoops, I didn't re-think the logic of it.
    I have the negative condition in there because I originally started with two commands, and spent maybe half an hour frustrated because I could not figure out why, even with cmd arguments, it asked me for input.

    I eventually figured out that because I was shifting @ARGV, there was nothing left afterwards. ;)