perl -p -i.bak -e 's:CLASSATTRIBUTES:classattributes:g' * #### my @files = qw( foobar zoot ); for my $file ( @files ) { ## Read the contents of the file open FILE, "<$file"; my $contents; do { local $/; $contents = ; }; close FILE; ## Make your changes $contents =~ s:CLASSATTRIBUTES:classattributes:g; ## Write the modified contents back to the file open FILE, ">$file"; print FILE $contents; close FILE; }