As soon as the two lines both begin with the same pair of characters, $1 is no longer defined. What am I missing here?#!/usr/bin/perl use strict; use warnings; my ($test, $count); # WORKS $test = <<'END'; ABCD DEFG END $count = ($test =~ s/(BC?[DE])//gi); print "Removed: <<$1>>\nCOUNT: $count\n"; # THIS ALSO WORKS $test = <<'END'; ABCD AEFG END $count = ($test =~ s/(BC?[DE])//gi); print "Removed: <<$1>>\nCOUNT: $count\n"; # FAILS $test = <<'END'; ABCD ABFG END $count = ($test =~ s/(BC?[DE])//gi); print "Removed: <<$1>>\nCOUNT: $count\n";
In reply to Bug or feature? s/// and the g option by Belgarion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |