Please note in your node any substantive changes that you make (changing the code is a substantive change).
Actually once the variable name problem was fixed my earlier sample code wasn't so good. However the following revised code works as expected:
use strict; use warnings; my @_lines = map {"$_\n"} split /\n/, <<LINES; ABC in the first line but not the second LINES foreach my $line (@_lines) { my $templine = $line; print "$templine"; # or print "$line"; if ($templine =~ /(ABC)/) {print "$1 = the line (1)\n";} } foreach my $_line (@_lines) { my $templine = $_line; ############ print "$templine"; ############ # or print "$line"; if ($templine =~ /(ABC)/) {print "$1 = the line (2)\n";} }
Prints:
ABC in the first line ABC = the line (1) but not the second ABC = the line (2)
If this is showing your failure mode then I don't understand what the problem is. If it doesn't show your failure mode then modify my sample code until it does and post the updated code along with the "bad" output.
In reply to Re^3: Printing the variable makes the next match code work. Why?
by GrandFather
in thread Printing the variable makes the next match code work. Why?
by scaryfast
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |