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