in reply to Re^2: Identifying Reverse Position of Specific Character in a String
in thread Identifying Reverse Position of Specific Character in a String

There's no benefit to that in this case, since the function makes no attempt to alter $_.

Furthermore, using the for(shift) idiom with code that does modify $_ is dangerous, unless your intent is to modify $_[0].

As for pos, one of the lessons you do (or should) learn early in your Perl edjication is to call pos as soon after the regex that sets it as possible — ideally, immediately after it. Otherwise, you're taking a gamble.

We're building the house of the future together.
  • Comment on Re^3: Identifying Reverse Position of Specific Character in a String
  • Download Code

Replies are listed 'Best First'.
Re^4: Identifying Reverse Position of Specific Character in a String
by ikegami (Patriarch) on Aug 25, 2006 at 20:02 UTC
    since the function makes no attempt to alter $_.

    Odd, I see two things that modify it. An assignment, and the regexp alters the associated pos. The point of local is to protect the caller, but it doesn't necessarily do so in this situation.

      Point. Or two. ;-)