Thanks Eily. It works now :)
I'll have to remember to watch out for that magical <> feature you mentioned. I never realised it works like that... Fortunately I usually shift parameters from @ARGV.
You can find the documentation for the feature in perlop (search for "The null filehandle"). And you'll find more info on the problems of the magical <> and a safer version here