in reply to older files

Your problem is that you're trying to re-invent a well written and well tested wheel, and get it wrong along the way.

I recommend using DateTime, Data::Calc or a similar module to do your calculation.

(This here looks very suspicious, just look at the units associated (notionally) with each variable:

my $findtime=$sec+$min+$hour;

But fixing it not worth the effort. The modules can do the date calculations much better).