in reply to Find, copy & rename

The canonical way of passing parameters to a sub-routine is by using the @_ array and shifting the value of the parameter(s) into whatever variable(s) you use inside the sub-routine (preferably a variable declared with my).

I think there are lots of other things wrong (or at least, strange) with your sub-routine, but perhaps you first solve the parameter passing issue and then we look at the rest.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law