Skip Menu |

This queue is for tickets about the MailTools CPAN distribution.

Report information
The Basics
Id: 23470
Status: rejected
Priority: 0/
Queue: MailTools

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: allow user to specify that arg is a filehandle
fileno() is an insufficient test for whether something is a filehandle. Some handle-like objects, like IO::Scalar, return undef to fileno. This patch allows the user to force the treatment of ARG as a filehandle. -- rjbs
Subject: filehandle.patch
diff -Nur MailTools-1.74/Mail/Internet.pm MailTools-1.74-rjbs/Mail/Internet.pm --- MailTools-1.74/Mail/Internet.pm 2006-01-21 04:16:10.000000000 -0500 +++ MailTools-1.74-rjbs/Mail/Internet.pm 2006-11-17 20:55:23.000000000 -0500 @@ -61,16 +61,16 @@ if(defined $arg) { - if(ref($arg) eq 'ARRAY') - { - $me->header($arg) unless exists $arg{Header}; - $me->body($arg) unless exists $arg{Body}; - } - elsif(defined fileno($arg)) + if($arg{FileHandle} or eval { defined fileno($arg) }) { $me->read_header($arg) unless exists $arg{Header}; $me->read_body($arg) unless exists $arg{Body}; } + elsif(ref($arg) eq 'ARRAY') + { + $me->header($arg) unless exists $arg{Header}; + $me->body($arg) unless exists $arg{Body}; + } } return $me; @@ -782,6 +782,11 @@ C<\n> (LF). If Body is given then C<Mail::Internet> will not attempt to read the body from C<ARG> (even if it is specified). +=item B<FileHandle> + +If this option is true, then the C<ARG> will be treated as if it were a +file descriptor, even if it does not seem to be one. + =back The Mail::Header options C<Modify>, C<MailFrom> and C<FoldLength> may
I really dislike this change. It is much nicer to use the fact that all these other File-like things are based on 'IO::Handle'.