in reply to organizing large flat modules? use, require, do, ...

Any ideas on how I can avoid 4000 lines of many module subs in one source file?

Um ... put package Mod; at the top of each of Mod-part1.pm and Mod-part2.pm?

The package statement doesn't propagate beyond file boundaries so you need to be explicit in your individual files

Update: Sorry, I didn't see what you had written about use base (that's what I get for skimming rather than reading). Hmm. You can always declare your subs like this:

sub Mod::foo { ... }

And if variables are a problem too, then you would add

use vars qw($Mod::var1 $Mod::var2 @Mod::var3 %Mod::etc);

at an appropriate place. Note that this still won't make __PACKAGE__ have the value of Mod

Why are you using __PACKAGE__ anyway? Do you need to? As chromatic said, perhaps you need to re-think your design.

Also, you can always redeclare everything at the top of each module part:

# Mod-part1.pm package Mod; use base qw(Meta); ... # Mod-part2.pm package Mod; use base qw(Meta); ...

Replies are listed 'Best First'.
Re: Re: organizing large flat modules? use, require, do, ...
by halley (Prior) on Jan 10, 2004 at 19:19 UTC
    (I was only using __PACKAGE__ to see why things weren't being put in the right namespace.)

    The sub Mod::foo { } suggestion was a new thought, but like __PACKAGE__, the magic identifier SUPER was not correct. I would rather use SUPER than hardwire the base class, but it's pretty arbitrary.

    As for the many suggestions to rethink the design; yes, it's a good idea to rethink it. However, I've rethought, and in my particular case, it rightfully should be one class with a few semi-distinct duties that are not easy to aggregate or embed or delegate. I'm working near the base of a large class hierarchy, and the base classes really must cover their core duties.

    --
    [ e d @ h a l l e y . c c ]

      Then I would think that restating the package and base class (and whatever else you need) at the start of each module part is your best bet.