Hi All,
  I have a main object that I don't want to just keep exporting new 
methods to. So instead I'm exporting new objects. The way I'm doing it 
is like so (cut down):-

package ExtObj;

use strict;
use warnings;

use vars qw ( $VERSION @ISA @EXPORT );

require Exporter;
@ISA = qw(Exporter);
@EXPORT = ( 'ExtObj' );

my $extobj;

sub import {
    $extobj = new ExtObj::guts;
    ExtObj->export_to_level(1, @_);
}#sub

sub ExtObj {
    unless ( $extobj->{params}->{__orig_obj} ) {
        $extobj->{params}->{__orig_obj} = shift;
    }#unless
    return $extobj;
}#sub

package Plugme::guts;

sub new {
    my $class = shift;
    my $obj = {
        params => {},
    };
    bless( $obj, $class );
    return $obj;
}#sub

sub new_methods {
    #code
}#sub

1;


Feedback and questions please.

I'm not happy with the ExtObj sub, particularly:-
    unless ( $extobj->{params}->{__orig_obj} ) {
        $extobj->{params}->{__orig_obj} = shift;
    }#unless
I'm sure there is some clever way of getting the reference to the 
original object, or at least swap this for some sort of subref so the 
unless isn't ran each time the obj is called...

This gives me $OrigObj->ExtObj->new_methods;

Hope that makes sense :-\


Lyle

_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to