in reply to Re^3: Best practice for reading delimited file
in thread Best practice for reading delimited file

prematch is just a wordier name for $`

$PREMATCH is the same as $` but it's not the same as ${^PREMATCH}:

* $PREMATCH * $` The string preceding whatever was matched by the last successful pattern match, not counting any matches hidden within a BLOCK or eval enclosed by the current BLOCK. The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. To avoid this penalty, you can extract the same substring by using @-. Starting with Perl v5.10.0, you can use the /p match flag and the ${^PREMATCH} variable to do the same thing for particular match operations.

Source: perlvar.

Replies are listed 'Best First'.
Re^5: Best practice for reading delimited file
by SuicideJunkie (Vicar) on Oct 16, 2013 at 18:11 UTC

    Ah, nifty!

    Since Perl v5.10.0, you can use the /p match operator flag and the ${^PREMATCH} , ${^MATCH} , and ${^POSTMATCH} variables instead so you only suffer the performance penalties.

    Is that sentence missing a "once" at the end perhaps?

      I think it's missing "for this regexp, not for all regexps anywhere in your script+modules".

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

      That certainly is a curiously obscure assertion, given the performance statements a bit later in the documentation. I think you're correct that something is missing here, but I'm not sure it's "once at the end".

        Its just that that's the first thing you see when doing a search-find for the name. It makes it sound like you get all the performance penalties associated with $`.

        If it has all the same penalties as before then its clearly bad to use, so further details don't really matter. ;)