in reply to increasing value every time sub routine called

Have a look at sprintf for your leading zeros. Others have mentioned closures or subroutines incrementing a global variable. IMHO a closure is tidier, obviating the need for a global that might accidentally get tinkered with elsewhere in the code.

knoppix@Microknoppix:~$ perl -Mstrict -wE ' > my $rcIncrement = do { > my $value = 0; > sub { return sprintf q{%03d}, ++ $value }; > }; > > say $rcIncrement->() for 1 .. 3; > say q{-} x 10; > say $rcIncrement->() for 1 .. 3;' 001 002 003 ---------- 004 005 006 knoppix@Microknoppix:~$

I hope this is helpful.

Cheers,

JohnGG