in reply to Re: Where and when you should place 'use module;'?
in thread Where and when you should place 'use module;'?
'use module' statements have file scope.
They have package scope. Or rather, the require portion has program scope, the import portion has package scope.
package Foo; use Benchmark qw{cmpthese}; package main; cmpthese( -1, { ...etc... } ); __END__ Undefined subroutine &main::cmpthese called at - line 7.
update: It's worthwhile to add that import acting in package scope is conventional, not a rigid truth. import is free to do what it wants, but it is usually defined by Exporter (or like Exporter) to inject symbols into the caller's package scope.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Where and when you should place 'use module;'?
by Perl Mouse (Chaplain) on Oct 12, 2005 at 13:44 UTC | |
by fishbot_v2 (Chaplain) on Oct 12, 2005 at 14:23 UTC | |
by Moron (Curate) on Oct 12, 2005 at 15:01 UTC | |
by revdiablo (Prior) on Oct 12, 2005 at 15:22 UTC | |
by Perl Mouse (Chaplain) on Oct 12, 2005 at 15:36 UTC | |
by Moron (Curate) on Oct 12, 2005 at 15:27 UTC | |
| |
by fishbot_v2 (Chaplain) on Oct 12, 2005 at 16:32 UTC | |
by Moron (Curate) on Oct 13, 2005 at 11:37 UTC |