open(FILE, $file) or die $!; @lines = ; close FILE; for ($i = 0; $i <= $#lines; $i++) { if ($lines[$i] =~ /<% INCLUDE exclusives(\d+)\.tmpl %>/) { $num = $1; $num = $num == 1 ? 3 : 1; $lines[$i] =~ s/<% INCLUDE exclusives(\d+)\.tmpl %>/<% INCLUDE exclusives$num\.tmpl %>/; } else { next; } open(FILE, ">$file") or die $!; print FILE @lines; close FILE; #### $num = $num == 1 ? 3 : 1;