Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Can I force strictness on included files?

by jonadab (Parson)
on Jun 30, 2005 at 10:06 UTC ( [id://471259]=note: print w/replies, xml ) Need Help??


in reply to Can I force strictness on included files?

Are you sure you want to do that? I can't recommend it. As a rule, code that wasn't *designed* to run under strict, won't. Put another way, if the files in question don't have use strict in them, they probably also don't have their variables all predeclared and so on and so forth. It takes rather significant editing to make code of any nontrivial level of complexity run under strictures. Adding the strict declaration to it is, by comparison, a very minor additional thing to do.

Replies are listed 'Best First'.
Re^2: Can I force strictness on included files?
by Thilosophy (Curate) on Jun 30, 2005 at 10:24 UTC
    Good point.

    In my case, however, it is code that was designed to be run under strict. It is not any random code from outside our control, it is data files (that just happen to be in Perl) consisting of a single hashref or a single coderef. That the use strict is not in there is mere lazyness and forgetfulness (two of a Perl programmer's virtues).

    Unless there is a switch to turn on strict for all files, I think I will settle for the solution of slurping and eval'ing the file manually, adding the "use strict" in the process, as suggested by broquaint.

      If this is the case then I can't see what adding the stricture to the code will buy you, to be honest I wouldn't even bother.

      /J\

        It catches typos. My post was motivated by being bitten earlier today by a missing sigil and a resulting unwanted bareword. use strict would have made that error immediately obvious. So of course, I added the use strict in that particular file, but I'd like to have it everywhere now.

        Will Perl 6 be strict by default ?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found