[EMAIL PROTECTED] wrote: > I guess, you're the man! > > Your code works. I did not know of the Exporter. > > What happens if there are several package with the same name and exported? > > thanks, > rkl
Then you have to prepend the name. For some reason the term is slipping my mind, but a sub declared in an immediate scope will hide a similarly named sub imported from another package. Methods of the same name imported from more than one package will compete with each other. This should cause a compiler error. I'll see if I have time to test it before I head off to the day job. Nope. The last definition read overshadows any previous one. I modified the code in MyCommon::do_wrap() to eliminate the single quotes around the return value, and re-saved the file as MyCommon2.pm, then included both in the test_my_common.pl. When MyCommon2 was use'd after MyCommon, the string printed without quotes, when I reversed the order of inclusion, the single quotes were back. The compiler gave no warning or error, just took the most recent definition. MyCommon.pm package MyCommon; use strict; use warnings; use Exporter; our @ISA = 'Exporter'; our @EXPORT = qw(do_wrap); sub do_wrap { my $retval; if(length($_[0]) == 0) { $retval = "null"; } else { $retval = "'" . $_[0] . "'"; } return $retval; } 1; MyCommon2.pm: package MyCommon2; use strict; use warnings; use Exporter; our @ISA = 'Exporter'; our @EXPORT = qw(do_wrap); sub do_wrap { my $retval; if(length($_[0]) == 0) { $retval = "zero-length"; } else { $retval = $_[0]; } return $retval; } 1; test_my_common.pl: #!perl use strict; use warnings; use MyCommon2; use MyCommon; my $return = do_wrap('hello'); print "$return\n"; $return = MyCommon2::do_wrap('hello'); print "$return\n"; Command Line testing: Greetings! E:\d_drive\perlStuff>test_my_common.pl 'hello' hello Greetings! E:\d_drive\perlStuff> Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]