--- name: pos status: documented runtime: pp source: src/runtime/pp/tie.rs --- ```{index} single: pos; Perl built-in (pp runtime) ``` # pos ## Synopsis ```perl $str =~ /pattern/g; my $p = pos($str); # position after last /g match pos($str) = 0; # reset match position my $p = pos; # defaults to $_ ``` ## Description Gets or sets the position of the last `m//g` match on a string. As an rvalue, returns the character offset where the most recent global (`/g`) match left off, or `undef` if no match has been performed on that string. As an lvalue, sets the starting position for the next `m//g` match. Without an argument, operates on `$_`. Positions are stored in a side table (`pos_table`) keyed by string content. ## See also m//g, reset