in reply to Re^3: Subroutine to delete one file and copy one file to another
in thread Subroutine to delete one file and copy one file to another

Right on (in para 2 of pme's Re^3: Subroutine to delete one file and copy one file to another) re the sub,
  ...but uhmm, not so much re:
        "... add 'my' to the variable declarations wherever (emphasis supplied) the error messages indicates."

Not a good idea: $YEAR gets an error message at lines 20 & 22 (and possibly some others; TL, DR) while $year and several others also have multiple instances.

In this case, the $YEAR in Ln 22 is supposed to contain or represent the same value as that in Ln 20, so the one at 20 (in fact the whole list of vars there) should get a my.

But adding a my to the $YEAR in Ln 22 would break the process.

It may be that some of the vars in OP's code are instances (bad practice) of using the same name in different scopes. Simply iterating thru an edit/test cycle will probably not cure any problem of that character, but it's probable, IMHO, that some variables identified MORE THAN ONCE in the error messages are intended to be global.

In that case, adding a my before the first open parenthesis on Ln 20 will make many of Perl's help messages (because that's what error messages and warnings are)"go away". Adding a my before the first instance of each var cited in an error message may help OP to find most of the problems in the code shown. But marking all of them with mys will probably break the code and confuse the Seeker even further.


Precise language is the GodFather of precise code!