Hi,
I have a book called "Writing Perl Modules for CPAN" and it's my favourite
book ever! See if you can get a copy. In it is detailed a way to make
something private and enforcing it by using an anonymous sub.
This book will probably introduce you to Perl from the right direction,
since it makes sense for you to find out what Perl does and doesn't do in
comparison to C++ as soon as possible.
Anyway, the solution is you have your new sub return an anonymous sub that
then sets up the internal data using the my keyword... spot the problem
here??? Yes! Suddenly EVERYTHING is private (well, all of the variables
anyway) so that you need accessors/mutators for everything... which are
difficult to roll automatically in this case.
I guess the short answer is: it's possible, but don't bother!
J
Reference:
Sam Tregar, Writing Perl Modules for CPAN, Apress/Springer NY 2002
(Try
www.apress.com or
www.springer-ny.com)