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

Re: strict/warnings interference with global declarations

by davido (Cardinal)
on Nov 03, 2004 at 00:56 UTC ( #404800=note: print w/replies, xml ) Need Help??

in reply to strict/warnings interference with global declarations

require is a runtime feature. strict does a compiletime check. Since file2 used $var, but $var is declared in file1, and since file1 isn't 'loaded' until runtime, there's no way for strictures to know, when Perl compiles, that $var was declared in file1. So you get a compiletime error.

Keeping track of what order things happen in, helps to figure out what's going wrong. Here's a quick rundown of the sequence of events:

  1. Perl compiles with 'use strict' on.
  2. Perl discovers that you're using $var in, but hasn't yet loaded Strict complains.

If you had put our $var;, or use vars qw/$var/; in, strict wouldn't complain, and you'll be ok, so long as isn't a different package.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2021-10-28 01:03 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (95 votes). Check out past polls.