in reply to Substitution don't work

In your sample input there is no space between 0 and ]. In your regular expression you have the pattern .* ] (there's a space). Did you maybe need to put a /x modifier? Or eliminate that space in the pattern.

Also, this line: my $subst = // is not doing what you think. It is doing a match of $_ =~ // in scalar context and assigning the Boolean result to $subst. I think you probably wanted my $subst = '';, or my $subst = q//;.


Dave

Replies are listed 'Best First'.
Re^2: Substitution don't work
by AnomalousMonk (Archbishop) on Aug 24, 2015 at 11:18 UTC
    ... my $subst = // is not doing what you think. It is doing a match of $_ =~ // in scalar context ...

    Likewise
        my $regex =/\{\[%tqu .* ]}/;

    OldChamp: You seem to have warnings enabled, but if so, you should have posted the warning messages generated.


    Give a man a fish:  <%-{-{-{-<

Re^2: Substitution don't work
by OldChamp (Acolyte) on Aug 24, 2015 at 09:42 UTC

    Hi Dave, thank you for your help. I have removed the space and I have corrected the $subst to my $subst ='';, but I still get an empty file Out.txt.

    I'm just learning perl, I have programed in Visual Basic and VBA long long ago.

      but I still get an empty file Out.txt.

      You should print if you want your program to produce some output.