#!/usr/bin/perl use warnings; use strict; foreach my $file (<*.php>) { open FILE, ">$file" or die "$!"; while () { s/foot\.php/\.\/include\/foot\.php/; s/head\.php/\.\/include\/head\.php/; print FILE; } close FILE or die "$!"; }