#!/usr/bin/perl -w use strict; use File::Copy qw( cp ); opendir D, '.'; my @files = grep /\.html$/, readdir( D ); for ( @files ) { next if $_ eq 'new.html'; cp $_, "$_.bak"; cp 'new.html', $_; }