Subject: | bug using access=>'w' |
Date: | Tue, 26 May 2009 16:45:16 -0700 |
To: | bug-Mail-Box [...] rt.cpan.org |
From: | Mike Ekberg <emike1955 [...] gmail.com> |
Message body not shown because it is not plain text.
#! /usr/bin/perl
#dbx2mbox.pl <dbxfile> <mboxfile>
# convert <dbxfile> to <mboxfile>
$| = 1;
use strict;
use warnings;
use diagnostics;
use Mail::Transport::Dbx;
use Mail::Box::Mbox;
use Mail::Box::Dbx;
chomp (my $dbxfile = shift);
chomp (my $mboxfile = shift);
system ("/bin/rm -f $mboxfile");
-e $dbxfile || die "cannot find dbxfile $dbxfile";
print "opening existing dbxfile $dbxfile\n";
my $from = Mail::Box::Dbx->new(folder => $dbxfile)
or die "cannot read dbxfile $dbxfile using Mail::Box:Dbx->new:$!";
print "dbxfile $dbxfile is open\n";
print "creating mboxfile $mboxfile\n";
my $to = Mail::Box::Mbox->new(folder => $mboxfile,
access => 'rw', create => 1) or die "cannot create new mbox file using Mail::Box::Mbox->new: $!";
print "mboxfile $mboxfile is created\n";
print "copying dbxfile($dbxfile) -> mboxfile($mboxfile)\n";
$from->copyTo($to) || die "from->copyTo($mboxfile) failed:$!";
exit;
Hi:
I am reporting a likely bug in Mail:Box::MBox.The following example code
from Mail::Box::Dbx fails in the following way::
Code:
#! /usr/bin/perl
#dbx2mbox.pl <dbxfile> <mboxfile>
# convert <dbxfile> to <mboxfile>
$| = 1;
use strict;
use warnings;
use diagnostics;
use Mail::Transport::Dbx;
use Mail::Box::Mbox;
use Mail::Box::Dbx;
chomp (my $dbxfile = shift);
chomp (my $mboxfile = shift);
system ("/bin/rm -f $mboxfile");
-e $dbxfile || die "cannot find dbxfile $dbxfile";
print "opening existing dbxfile $dbxfile\n";
my $from = Mail::Box::Dbx->new(folder => $dbxfile)
or die "cannot read dbxfile $dbxfile using Mail::Box:Dbx->new:$!";
print "dbxfile $dbxfile is open\n";
print "creating mboxfile $mboxfile\n";
my $to = Mail::Box::Mbox->new(folder => $mboxfile,
access => 'w', create => 1) or die "cannot create new mbox file
using Mail::Box::Mbox->new: $!";
print "mboxfile $mboxfile is created\n";
print "copying dbxfile($dbxfile) -> mboxfile($mboxfile)\n";
$from->copyTo($to) || die "from->copyTo($mboxfile) failed:$!";
exit;
Run as:
# do simple dbx test using dbxtest.pl or dbx2mbox.pl
mkdir -p dbxTest
/bin/rm -f dbxExamples/test.mbox
dbx2mbox.pl dbxExamples/test.dbx dbxTest/test.mbox
opening existing dbxfile dbxExamples/test.dbx
dbxfile dbxExamples/test.dbx is open
creating mboxfile dbxTest/test.mbox
mboxfile dbxTest/test.mbox is created
copying dbxfile(dbxExamples/test.dbx) -> mboxfile(dbxTest/test.mbox)
Filehandle GEN4 opened only for output at
/usr/lib/perl5/5.10/i686-cygwin/IO/Handle.pm line 421 (#1)
(W io) You tried to read from a filehandle opened only for writing, If
you intended it to be a read/write filehandle, you needed to open it
with "+<" or "+>" or "+>>" instead of with "<" or nothing. If you
intended only to read from the file, use "<". See perlfunc/open.
Another possibility is that you attempted to open filedescriptor 0
(also known as STDIN) for output (maybe you closed STDIN earlier?).
The above passes if I make this change:
Was:
my $to = Mail::Box::Mbox->new(folder => $mboxfile,
access => 'w', create => 1) or die "cannot create new mbox file
using Mail::Box::Mbox->new: $!";
New:
my $to = Mail::Box::Mbox->new(folder => $mboxfile,
access => 'rw', create => 1) or die "cannot create new mbox file
using Mail::Box::Mbox->new: $!";
It is certainly possible this a problem w/ the example code that I
pulled from Mail::Box::Dbx....
I'm using the following versions:
Mail-Box-2.089-P2kMI9
Mail-Transport-Dbx-0.07-Sg64D2
This is all run on a fairly recent version of cygwin, perl 5/5.10.
Best Regards,
Mike Ekberg