pos
pos $scalar
- Returns the location in scalar where the last
m//gsearch over scalar left off. It returns the offset of the character after the last one matched. This is the offset where the nextm//gsearch on that string will start. Remember that the offset of the beginning of the string is . For example:
$grafitto = "fee fie foe foo"; while ($grafitto =~ m/e/g) { print pos $grafitto, "\n"; }
prints , , , and , the offsets of each of the characters following an e". Theposfunction may be assigned a value to tell the nextm//gwhere to start.