s///
returns the number of substitutions made. An equivalent of your code would be:
if ($line =~ s/^REF: //) {
# do something else
}
Question
The answer is probably obvious, but I'm wondering if there's a shorter way to write this:
if ($line =~ m/^REF: /){
$line =~ s/^REF: //;
# do something else
}
Solution
s///
returns the number of substitutions made. An equivalent of your code would be:
if ($line =~ s/^REF: //) {
# do something else
}
OTHER TIPS
You mean?
if ($line =~ s/^REF: //){
print $line."\n";
}
else {
print "Line not touched\n";
}