Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > problem with Net::SMTP::Multipart

Reply
Thread Tools

problem with Net::SMTP::Multipart

 
 
ecureuil
Guest
Posts: n/a
 
      05-25-2006
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


 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      05-25-2006
ecureuil wrote:

> Could you explain me what these lines mean?


Yes, however they're well documented.

> if (ref($file) eq 'ARRAY') { # ref and ARRAY ?


perldoc -f ref

> $displayname = $file->[0]; # $file->[0] ?
> $file = $file->[1]; # $file->[1] ?


perldoc perlref Look for arrayref.

 
Reply With Quote
 
 
 
 
Eric Schwartz
Guest
Posts: n/a
 
      05-25-2006
"J. Gleixner" <(E-Mail Removed)> writes:
> ecureuil wrote:
> > Could you explain me what these lines mean?

>
> Yes, however they're well documented.


Albeit incorrectly or misleadingly.

> > if (ref($file) eq 'ARRAY') { # ref and ARRAY ?


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
 
Reply With Quote
 
ecureuil
Guest
Posts: n/a
 
      05-27-2006

"Eric Schwartz" <(E-Mail Removed)> a écrit dans le message de news:
http://www.velocityreviews.com/forums/(E-Mail Removed)omain...

| 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments