#!/usr/local/bin/perl use strict; use warnings; my @argv; my $dir = $ARGV[0]; my @files = glob "${dir}'*pl*'"; foreach (@files) { next if -d; (my $txt = $_) =~ s/pl$/txt/; rename($_, $txt); }