Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to find barewords in perl code?

by JavaFan (Canon)
on Jun 01, 2010 at 16:02 UTC ( #842643=note: print w/ replies, xml ) Need Help??


in reply to How to find barewords in perl code?

And if it wasn't for perlcritic, I'd think that /(?:open(?:dir)?|print|close|flock|readdir)\s+[A-Za-z] would find most of them, with little false positives. (Of course, one can easily construct false positives and false negatives).


Comment on Re: How to find barewords in perl code?
Download Code
Re^2: How to find barewords in perl code?
by moritz (Cardinal) on Jun 01, 2010 at 16:12 UTC
    I'd add a (?![,(]) to the end of that regex to exclude print functioncall() and print functionall, otherstuff.

    Now let the bikeshedding and micro-optimizations begin!

      Hmmm, forgot about function calls like that. For some reason, I assumed perl would warn. But even this is warning free:
      sub foo {shift} sub bar {1} print foo bar;
      and just prints 1.

      OTOH, in pre-5.6 days, when I was still using bare word file handles, I used all uppercase names, and I use all lowercase for subs, so /(?:print|...)\s+[A-Z]/ would have worked for my code.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-10-25 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (138 votes), past polls