note
buckaduck
<code>
# Your code
$_ =~ /^(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)$/;
my $value1=$1;
</code>
<p>
That is a very complicated way of doing what you really
want, which is probably this:
<code>
# My code
my ($value1) = split /\*/;
</code>
<p>
Next problem:
<code>
# Your code
unless($value1 ne $ag) {
s/$value1/$ag/g;
$save_list=$save_list.$_;
}
</code>
The <code>s///</code> substitution is useless.
This block of code only executes when <code>$value1</code>
equals <code>$ag</code>. So you're replacing the value with itself! I think you want <code>if()</code> rather than
<code>unless()</code>. And you're probably right about
removing the <code>/g</code> flag.
<p>
While we're at it, your <code>$value1</code> could have
special regex characters, so you should protect
them with <code>\Q..\E</code> syntax:
<code>
# My code
if ($value1 ne $ag) {
s/\Q$value1\E/$ag/;
$save_list=$save_list.$_;
}
</code>
<p>
<b>Update:</b> Added <code>\Q..\E</code> recommendation.
<p>
buckaduck
210909
210909