An almost identical question was asked
here, and I suggested
this code, as an example of a subroutine which creates a "closure" to manage the desired progress meter.
Please try it out; I think it will do what you need.
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/