http://www.perlmonks.org?node_id=471262


in reply to Re: Can I force strictness on included files?
in thread Can I force strictness on included files?

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.

Replies are listed 'Best First'.
Re^3: Can I force strictness on included files?
by gellyfish (Monsignor) on Jun 30, 2005 at 10:31 UTC

    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 ?

        Will Perl 6 be strict by default?

        The answer to this is not as simple as 'yes' or 'no'. What do you mean by "by default"? What do you mean by "Perl6"? The Perl6 compiler will, by default, assume it is being fed Perl5 code... Also, the details have changed at least once since they were originally given; the original thinking was that a Perl6 package declaration would trigger strictness by default, so that modules would be strict by default, but other Perl6 code, by default, would not be. The current (last I checked) thinking is that -e will turn off strictness by default, but otherwise it will be on by default for Perl6 code, unless you change it. It will still be off by default for Perl5 code, which is the default, for compatibility reasons, so I guess you could say that the default default in Perl6 is for strictures to be off, but the Perl6 default is for them to be on. (If you're not confused yet, you should definitely subscribe to perl6-language.)