Class::Std causing compilation errors

I'm getting some strange problems with a couple of simple Class::Std
modules I'm working on. Either module works fine by itself, but when I
reference one from the other I get warnings and errors at compile time. My
test script doesn't do anything except use one of the modules:

#!/usr/bin/perl -w

use strict;
use lib '.';
use Mailbox;

(module code below)

When I try to run the script I get this:

Use of uninitialized value in pattern match (m//) at
/usr/lib/perl5/site_perl/5.8.8/Email/Simple.pm line 78.
Use of uninitialized value in split at
/usr/lib/perl5/site_perl/5.8.8/Email/Simple.pm line 100.

For some reason code in Email::Simple seems to be getting executed during
the CHECK phase. When I run perl -c I get the same result.

I know Class::Std works its magic during the CHECK phase but I'm not smart
enough to figure out what the code actually does.

Is this a problem with Class::Std, or am I doing something wrong?

The modules look like this:

package Mailbox;

use strict;
use warnings;
use Message;

use Class::Std;
{
my %dbh_of :ATTR;
my %filename_of :ATTR( :get<filename> );

sub BUILD
{
my ($self, $id, $args_ref) = [at] _;

my $filename = $args_ref->{filename};
$filename_of{ $id } = $filename;
}

sub import
{
my ($self, $data) = [at] _;

my $msg = Message->new({ data => $data });
my $msg_obj = $msg->get_msg_obj();
my [at] from = $msg_obj->header('from') || '';
}
}

1;

and

package Message;

use strict;
use warnings;
use Email::Simple;

use Class::Std;
{
my %msg_obj_of :ATTR( :get<msg_obj> );

sub BUILD
{
my ($self, $id, $args_ref) = [at] _;
my $msg_obj = Email::Simple->new($args_ref->{data});
$msg_obj_of{ ident($self) } = $msg_obj;
}
}

1;
Walter Heukels [ Sa, 24 November 2007 23:08 ] [ ID #1878107 ]

Re: Class::Std causing compilation errors

On 2007-11-24, Walter Heukels <wmh [at] xs4all.nl> wrote:

> I'm getting some strange problems with a couple of simple Class::Std
> modules I'm working on. Either module works fine by itself, but when I
> reference one from the other I get warnings and errors at compile time. My
> test script doesn't do anything except use one of the modules:

Never mind, I'm an idiot. The moral of the story: don't use "import" as a
method name.

Walter
Walter Heukels [ So, 25 November 2007 16:23 ] [ ID #1878563 ]
Perl » comp.lang.perl.modules » Class::Std causing compilation errors

Vorheriges Thema: Duty Free European cigarettes
Nächstes Thema: RFC: Bridge AppConfig and Config::Model