in reply to Can't use string ("MODULE") as a HASH ref while "strict refs" in use

Line 816 of Mail/Box.pm reads:
$self->{MB_message_type}->coerce($message);
running the code in the debugger reveals that this is called at the $folder->addMessage($msg); line.

the problem is that create() does not return an object, (even though the docs claim it's a constructor).

To work around the problem:

Mail::Box::Mbox->create($foldername, access => 'rw'); my $folder = Mail::Box::Mbox->new(folder => $foldername);

Replies are listed 'Best First'.
Re^2: Can't use string ("MODULE") as a HASH ref while "strict refs" in use
by markov (Scribe) on Aug 10, 2004 at 20:14 UTC
    The method documentation was in the wrong section. For the next release, it will move from "Constructors" to "Internals". The right way to open a file, and create it if is doesn't exist yet is very file-open like:
     my $mbox = Mail::Box::Mbox->new(folder => $f,
       access => 'rw', create => 1);
    
    Besides, if you create a message, you always create a Mail::Message, not some Mail::Box::Message, because Mail::Box::Message have some knowledge about location in them, where the message you have created has none yet. It gets a location at $f->addMessage($msg), and will change type at that moment (in this case into a Mail::Box::Mbox::Message).
Re^2: Can't use string ("MODULE") as a HASH ref while "strict refs" in use
by m5m5m (Initiate) on Aug 10, 2004 at 19:11 UTC
    Joost, Your solution works. Thanks ! mm.