Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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]
NodeReaper lights some incense and reads Tool and Die

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-02-20 20:12 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.