Class::Std causing compilation errors

Class::Std causing compilation errors

am 24.11.2007 23:08:26 von Walter Heukels

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 );

sub BUILD
{
my ($self, $id, $args_ref) = @_;

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

sub import
{
my ($self, $data) = @_;

my $msg = Message->new({ data => $data });
my $msg_obj = $msg->get_msg_obj();
my @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 );

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

1;

Re: Class::Std causing compilation errors

am 25.11.2007 16:23:24 von Walter Heukels

On 2007-11-24, Walter Heukels 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