>perl -nlE "say sprintf qq(caption%03s.txt),$count++" one.txt two.txt three.txt
caption000.txt
caption001.txt
caption002.txt
####
>perl -nlE "say sprintf q(caption%03s.txt),$1 if $ARGV =~ /.*([\d]+).*/" one01.txt one02.txt
caption001.txt
caption002.txt
##
##
ls -l
-rw-rw-r-- 1 io io 0 feb 2 13:28 one.txt
-rw-rw-r-- 1 io io 0 feb 2 13:28 three.txt
-rw-rw-r-- 1 io io 20 feb 2 13:37 two.txt
perl -nlE 'say "processed $ARGV" if eof' *.txt
processed two.txt
##
##
perl -MTie::Scalar -M"5;{package SN; use parent -norequire => 'Tie::StdScalar';sub FETCH {print qq(Opening ${$_[0]}); ${$_[0]}}}; tie $ARGV, SN"
-nlE "say qq(\tprocessed $ARGV) if eof" 001.txt 002.txt 003.txt
Opening 001.txt
Opening 002.txt
Opening 002.txt
processed 002.txt
Opening 003.txt