use warnings; use strict; package My::Mondo::Class; # This class is defined in multiple files - see use My::Mondo::Class_1; use My::Mondo::Class_2; use My::Mondo::Class_3; #### use strict; use warnings; package My::Mondo::Class; # methods and variable initializations that depend only # on stuff declared in My::Mondo::Class or earlier parts # in the sequence, i.e. if this is My::Mondo::Class_2 then # it only references variables and methods in # My::Mondo::Class and My::Mondo::Class_1 #### #Foo.pm use strict; use warnings; package Foo; use Foo_1.pm; use Foo_2.pm; # Foo_1.pm use strict; use warnings; package Foo; my $HELLO; our $GOODBYE; sub hello { return "Hi!"; } # Foo_2.pm use strict; use warnings; package Foo; #note: also package Foo #$HELLO='Bonjour' #compiler complains - see below for why $Foo::HELLO='Bonjour'; #this is OK - see below for why #$GOODBYE='Au revoir' #compiler complains - see below for why $Foo::GOODBYE='Au revoir'; #this is OK - see below for why # calling hello() without qualification is OK, so long # as the package is Foo (which it is) print hello() . ": Hello=$Foo::HELLO, Goodbye=$Foo::GOODBYE\n";