in reply to Private Classes - Same or Separate Files?

Well, my first thought is: you cant do this. period.

The reason being is anyone, anywhere can do

my $x=bless {},"My::B";
and it doesnt matter what else you have done or do.

Perls philosophy is "Id prefer you stay out of my living room because I ask you to, not because I have a shotgun." so you arent allowed a shotgun.

But i was thinking you could do something simple, a basic caller check to see if the calling sub originated in a module that @ISA "My::A". If it isnt then you could fail, if it is then everything is happy. Something like the following untested snippet

croak "Must be called from a My::A class or subclass." unless UNIVERSAL::isa(scalar caller(),"My::A");
Apologies if im not communicating very well, im coming down with the flu.

<STONG>UPDATE
I think I sortof answered a question that Masem wasnt asking. :-) If the issue is regarding an aesthetic descion in how to indicate usage through form I would go (and have often done so) with having the 'private' class defined in the same file as the 'public', but at the end of file. Perhaps following some kind of comment that indicates that the contained classes are 'private' utility classes employed by the 'public' one.

Yves / DeMerphq
--
When to use Prototypes?
Advanced Sorting - GRT - Guttman Rosler Transform