my $dir = "c:/"; while (<$dir*.pl>) { my ($old,$new); $old = $new = $_; $new =~ s/pl$/bak/; rename $old, $new; }