http://qs1969.pair.com?node_id=915699


in reply to Re: $` $' in bash??
in thread $` $' in bash??

It's silly to keep using the bad variables instead of /p if you're going to use the English names.

perl -lane '$F[1]=~s/(chr\w[^_]?)_.*\b/$1/p;print ${^PREMATCH}. "\t". +$F[1] ."\t" .${^POSTMATCH}'

Replies are listed 'Best First'.
Re^3: $` $' in bash??
by Sandy (Curate) on Jul 21, 2011 at 16:37 UTC
    Actually, I never use English, so I am not sure what it is that you are saying.

    bad variables??

    What is the reason for using ${^PREMATCH} instead of $PREMATCH?

      I never use English, so I am not sure what it is that you are saying.

      You did in the post to which I replied.

      What is the reason for using ${^PREMATCH} instead of $PREMATCH?

      Quote perlre: "Once Perl sees that you need one of $& , $` , or $' anywhere in the program, it has to provide them for every pattern match. This may substantially slow your program."

      ${^PREMATCH} and the like are only set on demand (/p), so Perl doesn't need to preemptively populate it whenever you perform a match.