I completely understand the way the Perl's namespaces work. Here is what confused me. In my module, I created a function that connects to a MySQL database and then returns a DB handle. In the script that receives the DB handle, I removed the 'use DBI;' line. I can make queries against the database without problems. Why does this work?

[EMAIL PROTECTED] wrote:
That would be true in some languages. Not in Perl. Modules only "exist" in the lexical scope (usually a block, in this case a file/package). So, there's no danger in polluting namespace from that module for sure. But, as with everything else in Perl, you can access it if you go out of your way.

So, if you use Data::Dumper in the Foo::Bar class, and you call the Foo::Bar class (via use Foo::Bar), you'd have to do &Foo::Bar::Dumper to use it. If you understand. Which you probably don't. So wait until someone else answers. :-)

Will

In a message dated 2/17/2004 7:21:35 PM Eastern Standard Time, [EMAIL PROTECTED] writes:
I've been using Perl for about a year. I'm writing my own module that contains some custom functions that I use a lot. In doing this, I started wondering how modules work. For example, if my module has 'use SomeModule;' and a script I write has 'use MyModule;', does that mean that I am effectively saying 'use SomeModule;' in my script?




--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to