Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

(jeffa) Re: require() turns off strict?

by jeffa (Bishop)
on Jan 04, 2003 at 18:47 UTC ( [id://224285]=note: print w/replies, xml ) Need Help??


in reply to require() turns off strict?

use strict only works in the current package ... for example:
# file foo.pm package foo; $foo = 1; --------------------------- # file foo.pl use strict; use foo; print $foo::foo,$/; --------------------------- [jeffa@trinity perl]$ perl -c foo.pm foo.pm syntax OK [jeffa@trinity perl]$ perl -c foo.pl foo.pl syntax OK [jeffa@trinity perl]$ ./foo.pl 1
UPDATE:
s/package/scope/ -- thanks pg and hawtin :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: require() turns off strict?
by hawtin (Prior) on Jan 04, 2003 at 21:41 UTC

    #define PEDANTIC_MODE 1

    use strict only works in the current package

    I think you meant to say "use strict only works in the current lexical scope" which is slightly different from the current package. It could be that the two files had stuff from the same package (eg the main one).

    Update: Sorry I see that you have corrected that while I wasn't paying attention

      #ifdef PEDANTIC_MODE # include <limits.h> # define PEDANTIC_MODE INT_MAX #endif
      I think you meant to say "use strict only works in the current lexical scope" which is slightly different from the current package
      Nope, the current package holds for the length of the current lexical scope[1], which is usually the file-level lexical scope. See the docs for more info.
      HTH

      _________
      broquaint

      [1] although the 5.005 docs say it is dynamically scoped but I'm pretty sure it's lexically scoped because it takes effect at compile-time which isn't orthogonal with dynamically scoping

Re: (jeffa) Re: require() turns off strict?
by OM_Zen (Scribe) on Jan 05, 2003 at 03:18 UTC
    Hi ,

    The mod-perl , when the cgi or pl is under mod-perl ,then the use strict; is needed to avoid global variables and hence require "perl.pl" is recommended not to be really used ( the reason) .

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-05-18 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found