nachumk has asked for the wisdom of the Perl Monks concerning the following question:
The second loop matches nothing - I want this, but more importantly, I'd like something that can tell me that the regex engine has matched $ already. pos is set to 3 for each of those matches, so what other function can tell me that a string has already matched $? I need to use gc as I don't want a non-match to reset pos().my $str = "abc"; while ($str =~ m/.|$/gc) { printf("1: %d\n", pos($str)); } while ($str =~ m/.|$/gc) { printf("2: %d\n", pos($str)); } Output: 1: 1 1: 2 1: 3 1: 3
|
|---|