Hi!
This may not be strictly a CGI::Application question, but I
thought I'd ask here... this is my first attempt at using this
(and it appears *very* useful!). I may not be grokking
something about perl OOP.
I wanted to add an auth object to my application, so
I created something like this:
package myApp::Auth;
use warnings;
use strict;
use Exporter ();
our @ISA = qw( Exporter );
our @EXPORT = qw( new login );
our @EXPORT_OK = qw( new login );
our $VERSION = 0.1;
our %AUTH_MOD = (
POP => 'Mail::POP3Client',
FTP => 'Net::FTP',
IMAP => 'Net::IMAP::Simple',
LDAP => 'Net::LDAP',
RADIUS => 'Authen::Radius',
LOCAL => undef
);
sub new {
my $invocant = shift;
my $class = ref( $invocant ) || $invocant;
my $self = {
method => "LDAP",
module => undef,
server => undef,
user => undef,
pwd => undef,
@_,
};
bless ($self, $class);
if (!defined $self->_module()) {
$self->_module( $AUTH_MOD{$self->_method()} );
}
my $lib = $self->_module();
$lib =~ s/::/\//g;
$lib .= '.pm';
require $lib;
$lib->import();
return $self;
}
sub _module {
my $self = shift;
return $self->{module} unless @_;
local $_ = shift;
$self->{module} = $_;
...
When I use this from a simple script, everything is fine.
When I use it from within the CGI::App derived class (test)
via an instance script, I get:
Can't local object method "_module" via package "myApp::test"
So, some kind of namespace issue due to the fact that the
caller is an object (an instance of CGI::Application), it seems...
Any ideas about what lame-brain mistake I've made will be
greatly appreciated!!
-r
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.