[Israel.pm] A Proxy Module

Shlomi Fish shlomif at iglu.org.il
Thu Dec 2 09:11:37 PST 2004


I wrote the following object:

<<<
package MyProxy;

use strict;
use warnings;

use base 'Shlomif::NavMenu::Object';

use Shlomif::NavMenu::Tree::Iterator::Item;

use vars qw($AUTOLOAD);

sub new
{
    my $class = shift;
    my $self = {};
    
    bless($self, $class);
    
    $self->initialize(@_);
    
    return $self;
}

sub initialize
{
    my $self = shift;

    $self->{'**PROXIED**'} = 
        Shlomif::NavMenu::Tree::Iterator::Item->new(
            @_
        );
    
    return 0;
}

sub AUTOLOAD
{
    my $self = shift;
    my $func_name = $AUTOLOAD;
    $func_name =~ s!^MyProxy::!!;
    return $self->{'**PROXIED**'}->$func_name(@_);
}

1;
>>>

As can be seen it instantiates an object, and delegates all function calls to 
it.

Now I ask you to guess what I used it for.

Regards,

	Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

Knuth is not God! It took him two days to build the Roman Empire.



More information about the Perl mailing list