Hello Uri, Le Fri, 22 Jan 2010 22:08:38 -0500, Uri Guttman a écrit : > >>>>> "FP" == Frédéric Perrin <[email protected]> writes: > FP> # This works > FP> # use FRED1 qw/ fred1a /; > FP> # use FRED2; > > you don't need to use FRED2 in the main program. only FRED1 needs to > use it.
Yes, but that was sample code carved out of a more complex program. In my real program, both modules are used. > FP> require Exporter; > FP> our @ISA = qw/ Exporter /; > > those two lines can be replaced with the simpler: > > use base 'Exporter' ; ACK. > >>>>> FRED2.pm <<<< > FP> use strict; > FP> use warnings; > > 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. Doh ! Thanks. Indeed it works better with a package line. I'm surprised Perl didn't gave me a warning when using a module without a namespace. I can see the point of several namespaces in the same module, but what about modules without any namespaces ? Are there cases where this would be useful, and not confusing as here ? -- Fred -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
