in reply to Weird undefined variable warning

It's because pos is pointing to the end of the string to be matched and you are asking the match to start at pos (the /c qualifier). I have no idea why the error refers to $_[2], perhaps you'd like to file a bug report?

Replies are listed 'Best First'.
Re^2: Weird undefined variable warning
by dave_the_m (Monsignor) on Jan 18, 2008 at 23:36 UTC
    I have no idea why the error refers to $_[2], perhaps you'd like to file a bug report
    It is a bug, but not relating to reporting an index of 2 rather 0. The undef error is actually occuring at the last branch of the if/else tree (hence the 2, which features on that line - probably a mistake in the OP's code), but the wrong line number is being reported (a well-known and longstanding class of bug, will probably be fixed for 5.12.)

    Dave.

      Do'h, didn't spot that last elsif;( I'd got the error to disappear by resetting pos to 0 and it went away. We live and learn;)