in reply to Re^6: Using pos() inside regexp (no /e)
in thread Using pos() inside regexp
#!/usr/bin/perl use strict; use warnings; # 864348 $_='qwerty erk'; my $pos; my $foo = $_ =~ s/r/ $pos=pos(). "\n"; print pos(); print "\n"; ++( pos() ); print "\t" . pos() . "\n"; print($pos . "\n")/gex; print "Now, outside the regex, $pos";
Output:
3 4 3 8 9 8 Now, outside the regex, 8
(Note: as you wrote the one-liner in your previous, you wrote an illegal ref to $_; the $ does NOT need escaping in your one-liner.
... and I'm confused: "G" and "g" come and go in your posts... sometimes one; sometimes the other; and sometimes, not at all.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Using pos() inside regexp (no /e)
by braveghost (Acolyte) on Oct 10, 2010 at 15:58 UTC | |
by ww (Archbishop) on Oct 10, 2010 at 19:28 UTC | |
by braveghost (Acolyte) on Oct 10, 2010 at 20:44 UTC | |
by ww (Archbishop) on Oct 11, 2010 at 03:32 UTC | |
by braveghost (Acolyte) on Oct 11, 2010 at 10:33 UTC |