The main problem is in your regex declaration, you had / in there and it was being read as a regex and throwing errors about $regex not being initiated. as s//$regex///$subst//gi I think. Here is the error I was getting:
Use of uninitialized value $_ in pattern match (m//) at C:\User.....
Heres a solution I came up with:
use strict; use warnings; my $regex = '\{\[%tqu.*]}'; my $subst = ''; while(my $line = <DATA>) { $line =~ s/$regex/$subst/gi; print $line."\n"; } __DATA__ 1. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $18) + {[%tqu "What is White's next move?","","",g3,"",0,b6,"misses the wi +n:",0]} 2. g3 $1 13. g6 c3
Outputs:
1. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $18) + 2. g3 $1 13. g6 c3
In reply to Re: Substitution don't work
by james28909
in thread Substitution don't work
by OldChamp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |