Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: $` $' in bash??

by Sandy (Curate)
on Jul 20, 2011 at 17:22 UTC ( #915688=note: print w/ replies, xml ) Need Help??


in reply to $` $' in bash??

use English

perl -lane 'use English;$F[1]=~s/(chr\w[^_]?)_.*\b/$1/;print $PREMATC +H. "\t". $F[1] ."\t" .$POSTMATCH'


Comment on Re: $` $' in bash??
Download Code
Re^2: $` $' in bash??
by ikegami (Pope) on Jul 20, 2011 at 18:12 UTC

    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}'
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://915688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (14)
As of 2014-12-18 16:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls