Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Match a string with a regular ...Compile pattern (Berikutnya)
Regular expressions and pattern matching

Find or set the offset for the last/next m//g search

Daftar Isi

  • pos SCALAR

  • pos

    Returns the offset of where the last m//g search left off for thevariable in question ($_ is used when the variable is notspecified). Note that 0 is a valid match offset. undef indicatesthat the search position is reset (usually due to match failure, butcan also be because no match has yet been run on the scalar).

    pos directly accesses the location used by the regexp engine tostore the offset, so assigning to pos will change that offset, andso will also influence the \G zero-width assertion in regularexpressions. Both of these effects take place for the next match, soyou can't affect the position with pos during the current match,such as in (?{pos() = 5}) or s//pos() = 5/e.

    Setting pos also resets the matched with zero-length flag, describedunder Repeated Patterns Matching a Zero-length Substring in perlre.

    Because a failed m//gc match doesn't reset the offset, the returnfrom pos won't change either in this case. See perlre andperlop.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Match a string with a regular ...Compile pattern (Berikutnya)