http://qs321.pair.com?node_id=586676


in reply to Re: Defining classes and inheritance using packages within a single .pl file, without creating modules
in thread Defining classes and inheritance using packages within a single .pl file, without creating modules

Thank you for the good advice. For this particular case, IMHO the neatest way is to turn the { package ... } blocks into BEGIN { package ... } blocks, and remove the require Class1; line. If I don't remove that line, the block for Class1 is evaluated twice and I get a warning about new() and PrintHello() being redifined. The same warnings are issued if I use base qw(Class1); (without BEGIN). I guess that's because of the same reason (base implies a require). It seems therefore that use base is not the way to go for inline class definition.