Returns the offset of where the last m//g search left off for the variable in question ($_ is used when the variable is not specified). Note that 0 is a valid match offset. undef indicates that the search position is reset (usually due to match failure, but can also be because no match has yet been run on the scalar).
while (<DATA>) { /\d/g; say pos; } __DATA__ AB1CDEFGHIJKLM ABCDEFGHIJKLM7 ABCDEF7GHIJKLM ABC33DEFGHIJKLM ABCDEFGH123IJKLM ABCDEFGHIJKLM 12ABCDEFGHIJKLM
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial DeltronicsIn reply to Re: Identifying the position of match using regular expressions
by CountZero
in thread Identifying the position of match using regular expressions
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |