use strict; use warnings; my $template = "index.txt"; open (FILE,"$template") or die "Can't read from $template: $!"; my @file=<FILE>; close (FILE); open (FILE,">$template") or die "Can't write to $template: $!"; foreach (@file) { if (/<% INCLUDE file(1|2)\.txt %>/) { $1 == 1 ? s/<% INCLUDE file1\.txt %>/<% INCLUDE file2\.txt %>/ : s/<% INCLUDE file2\.txt %>/<% INCLUDE file1\.txt %>/; } print FILE; } close (FILE);
In reply to Re: modifying the search pattern of a file.
by t0mas
in thread modifying the search pattern of a file.
by damian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |