Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Location of 'use' statements

by Juerd (Abbot)
on Apr 19, 2003 at 14:16 UTC ( #251659=note: print w/ replies, xml ) Need Help??


in reply to Re: Location of 'use' statements
in thread Location of 'use' statements

I put pragmas like strict and warnings after my modules, I do this because as they are lexically scoped they have no effect on the contents of the used modules, and to me doing it this way makes this more clear, especially to a potentially inexperienced maintenance coder.

use Foo::Bar quux => ${'VERSION'}; use strict;
An extremely bad example, of course, but while playing with Exporter::Tidy, I noticed that when a use statement gets more complex, you really do want strict active there:
package Example; use Exporter::Tidy _map => { foo => \$foo }; use strict; my $foo; # silently making $Example::foo exportable
With strict, I would have found out my mistake of using $foo before it has been declared immediately:
package Example; use strict; use Exporter::Tidy _map => { foo => \$foo }; my $foo; # Global symbol "$foo" requires explicit package name ...

Clean solution: foo => \my $foo

Juerd
- http://juerd.nl/
- spamcollector_perlmonks@juerd.nl (do not use).


Comment on Re: Re: Location of 'use' statements
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2014-07-30 22:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls