leszekdubiel has asked for the wisdom of the Perl Monks concerning the following question:
output is:#!/usr/bin/perl my $a = " -1"; # remove trailing spaces warn "A: pos is ", pos $a; $a =~ /\G */gc; warn "B: pos is ", pos $a; $a =~ /\G(?=-)/gc or die "C: failed"; warn "D: pos is ", pos $a; $a =~ /\G(?=-)/gc or die "E: failed"; print "Z: passed";
Strange is that "pos $a" is 1, and look ahead for minus sign fails. B: situation is exactly the same as D:, but C: doesn't fail, but E: does...A: pos is at ./l2 line 7. B: pos is 1 at ./l2 line 10. D: pos is 1 at ./l2 line 13. E: failed at ./l2 line 14.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strange behaviour: continue with \G and /gc and look forward
by tybalt89 (Monsignor) on Dec 13, 2019 at 21:12 UTC | |
by leszekdubiel (Scribe) on Dec 13, 2019 at 21:35 UTC | |
|
Re: strange behaviour: continue with \G and /gc and look forward
by tybalt89 (Monsignor) on Dec 13, 2019 at 21:04 UTC | |
by ikegami (Patriarch) on Dec 14, 2019 at 17:33 UTC | |
by tybalt89 (Monsignor) on Dec 14, 2019 at 17:52 UTC | |
|
Re: strange behaviour: continue with \G and /gc and look forward
by ikegami (Patriarch) on Dec 14, 2019 at 17:43 UTC | |
|
Re: strange behaviour: continue with \G and /gc and look forward
by rsFalse (Chaplain) on Dec 16, 2019 at 10:21 UTC | |
|
Re: strange behaviour: continue with \G and /gc and look forward
by rsFalse (Chaplain) on Dec 16, 2019 at 10:30 UTC |