You have a couple of bugs in your regex. You are missing the closing '/'.
You need an e flag to evaluate the substitution expression. However as it stands that gets messy because of the mixture of string litteral characters and characters that represent a calculation. No way Perl can disambiguate that!
I'd be inclined to do it like this:
use strict; use warnings; my $str = "<tag1>Complete</tag1><tag2>3386</tag2><tag3>77844</tag3><ta +g4>11</tag4><tag5>30</tag5><tag6>4.7</tag6>"; if ($str =~ m|<tag1>Complete</tag1>|) { $str =~ s|(?<=<tag6>)(.*?)(?=</tag6>)|$1 * 100|e; } print $str;
Prints:
<tag1>Complete</tag1><tag2>3386</tag2><tag3>77844</tag3><tag4>11</tag4 +><tag5>30</tag5><tag6>470</tag6>
Note the use of strictures (use strict; use warnings;). The regex uses a look behind and a look ahead assertion to anchor the capture group so that the replaced text is only the number. The /e then gets the calculation done in the substitution.
In reply to Re: Manipulating a string in a tagged file
by GrandFather
in thread Manipulating a string in a tagged file
by rsriram
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |