problem with Net::SMTP::Multipart

E

ecureuil

hi,

Before, I use perl-Net-SMTP-Multipart-1.5-1

I modified Multipart.pm for this version :

http://rt.cpan.org/Public/Bug/Display.html?id=17936 for filename
# Keep only basename
$filename = $file;
$filename =~ s/^.*\/(.*?)/$1/;

and I add :
$self->datasend("From: ($arg{From})\n");

Now, I try with Net-SMTP-Multipart-1.5.4
I have problem with filename and From.

I modified 'From' as with version 1.5.1. It's ok.

But for filename ( FileAttach ), I have a problem.

sub FileAttach {
my $self = shift;
foreach my $file (@_) {
my $displayname;
if (ref($file) eq 'ARRAY') {
$displayname = $file->[0];
$file = $file->[1];
} else {
$displayname = $file;
}
....

Could you explain me what these lines mean?
if (ref($file) eq 'ARRAY') { # ref and ARRAY ?
$displayname = $file->[0]; # $file->[0] ?
$file = $file->[1]; # $file->[1] ?

Thank you
anne
 
E

Eric Schwartz

J. Gleixner said:
Yes, however they're well documented.

Albeit incorrectly or misleadingly.

the comment should be:

if (ref($file) eq 'ARRAY') { # file is an array ref?

There's no 'and' in the code anywhere.
$displayname = $file->[0]; # $file->[0] ?
$file = $file->[1]; # $file->[1] ?

If I *had* to document these at all, I'd say:

$displayname = $file->[0]; # show this name to the user
$file = $file->[1]; # use this name to get the real filename

The original comments imply to me that the references are being tested
somehow, which the code clearly doesn't support. This can increase
maintenance time, as the reader has to figure out whether or not to
believe the code or the comments.

As you point out, perlref (I prefer perlreftut for a nice gentle
intro) is sufficient to explain these two lines, at which point you
don't really need comments.

-=Eric
 
E

ecureuil

"Eric Schwartz" <[email protected]> a écrit dans le message de (e-mail address removed)...

| The original comments imply to me that the references are being tested
| somehow, which the code clearly doesn't support. This can increase
| maintenance time, as the reader has to figure out whether or not to
| believe the code or the comments.
|
| As you point out, perlref (I prefer perlreftut for a nice gentle
| intro) is sufficient to explain these two lines, at which point you
| don't really need comments.

thank you.

I understand now...for array and ref!

I have the problem 'FROM' with this perl module : Net::SMTP::Multipart

I add :
$self->datasend("From: ($arg{From})\n");

else the mail has not 'FROM'. It's blank...

anne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top