in reply to Processing ARGV

This doesn't solve your immediate problem, but it may come and bite you eventually. Your program will act as if no arguments were passed if you only passed one argument due to the line:
if ($#ARGV != 0)
What you probably want is:
if (@ARGV)