こゆこと?

http://d.hatena.ne.jp/tokuhirom/20070507/1178495922

package HTTP::MobileAgent::Plugin::UserID;
use strict;
use warnings;
use HTTP::MobileUserID;

our $VERSION = '0.01';

sub import {
    my $pkg = caller(0);
    
    my $getter = sub {
        my $self   = shift;
        my $userid = HTTP::MobileUserID->new($self);
        return +{ user_id => $userid->id , supported => $userid->supported };
    };
    
    my $key = join ",", __PACKAGE__, 'user_id';
    
    no strict 'refs';
    *{"${pkg}::user_id"} = sub {
        my ($self, ) = @_;
        $self->{$key} ||= $self->$getter;
        return $self->{$key}->{user_id};
    };
    *{"${pkg}::is_supported_user_id"} = sub {
        my ($self, ) = @_;
        $self->{$key} ||= $self->$getter;
        return $self->{$key}->{supported};
    }
}

1;

ふぅむ。確かにMobileAgentから扱えたほうが便利っぽくていいのかなぁ。