in reply to Confused about 'Name "main::whenfound" used only once:'

use warnings; sub argscan{ if ($#ARGV == 1) {return (0)}

All in all, what a mess! First, I'm confused by your indenting style. Then you miss the important

use strict;

line. And last (for these three lines), you write a sub to work on the global @ARGV variable. Subs are for having args passed into them. It may not that bad to have it like this, instead, but as a general rule it's not that nice a programming technique. And subs are typically for factorizing code that is to be applied in different situations, but if that's for cmd line arguments scanning, that code may well not be factorized away.

As far as the rest goes, I have the overall impression that you're doing far too much work, but I don't feel like trying to guess your task. May you describe in words what your script is supposed to do? We may offer a hopefully simpler alternative as a starting point to you...