Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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

- (do not use).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://251659]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-04-19 20:28 GMT
Find Nodes?
    Voting Booth?