Re: Can't use string ("MODULE") as a HASH ref while "strict refs" in use
Mark Overmeer <[email protected]> Tue, 10 Aug 2004 21:29:59 +0200
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Organization | MARKOV Solutions |
| Message-ID | <[email protected]> |
* M M ([email protected]) [040810 19:39]: > use strict; use English; use warnings; > use Mail::Box::Mbox; > > my $foldername = 'test.mbox'; > my $folder = Mail::Box::Mbox->create($foldername, access => 'rw'); "Create" does create the folder's file or directory, but doesn't open it. Use my $folder = Mail::Box::Mbox->new(folder => $foldername, access => 'rw', create => 1); or better my $mgr = Mail::Box::Manager->new; my $folder = $mgr->open($foldername, access => 'rw', create => 1); > my $msg; Leav that one out: you have a nested "my $msg" already > my $n =4; > while ($n--) { Or for(1..4) > my $msg = Mail::Box::Message->build(From => 'me', data => "Message > $n\n only two\nlines\n---\n"); > $folder->addMessage( $msg ); This is mistake as well. You cannot instantiate a Mail::Box::Message this way. Such a message has not only a header and a body, but also a file-location. That location will be assigned when you do the $folder->addMessage($msg) So: my $msg = Mail::Message->build(From => 'me', data => ... print ref $msg; # Mail::Message $folder->addMessage($msg); print ref $msg; # Mail::Box::Mbox::Message isa Mail::Box::File::Message isa Mail::Box::Message isa Mail::Message after a build, when you assign the message to a folder, it will get coerced into some other type to implement the folder specifics. -- That would work, MarkOv ------------------------------------------------------------------------ drs Mark A.C.J. Overmeer MARKOV Solutions [email protected] [email protected] http://Mark.Overmeer.net http://solutions.overmeer.net