my $pattern = pop @ARGV; for my $file (@ARGV){ my $new = $file; # apply pattern and rename }