>>>>> "FP" == Frédéric Perrin <[email protected]> writes:

  FP> Le Fri, 22 Jan 2010 22:08:38 -0500, Uri Guttman a écrit :

  >> i can't say for sure why this happens but you don't have a package
  >> name in FRED2.pm. so any subs it has are in package main::. so when
  >> you have the FRED1/FRED2 order, it seems to find fred2a in main:: but
  >> in the other order it won't. i can fathom the exact reason but the
  >> problem is likely just a missing package FRED2 line.

  FP> Doh ! Thanks. Indeed it works better with a package line.

  FP> I'm surprised Perl didn't gave me a warning when using a module without
  FP> a namespace. I can see the point of several namespaces in the same
  FP> module, but what about modules without any namespaces ? Are there cases
  FP> where this would be useful, and not confusing as here ?

why would it warn? a simple system could just put some subs into a
separate file as a module and load them into main:: for use by the main
script. no need for exporter as everything is in the main:: name
space. remember, the package has nothing to do with the file name. all
package does is set the default namespace for code that follows. the
convention is to keep the package name and file name related so
importing can be done. but in OO modules no importing should be done so
again there is no need to keep the package and file name related.

uri

-- 
Uri Guttman  ------  [email protected]  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to