problem with Net::SMTP::Multipart

Discussion in 'Perl Misc' started by ecureuil, May 25, 2006.

  1. ecureuil

    ecureuil Guest

    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
    ecureuil, May 25, 2006
    #1
    1. Advertising

  2. ecureuil

    J. Gleixner Guest

    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.
    J. Gleixner, May 25, 2006
    #2
    1. Advertising

  3. "J. Gleixner" <> 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
    Eric Schwartz, May 25, 2006
    #3
  4. ecureuil

    ecureuil Guest

    "Eric Schwartz" <> a écrit dans le message de news:
    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
    ecureuil, May 27, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. c# newbie
    Replies:
    3
    Views:
    5,891
  2. Replies:
    3
    Views:
    1,075
    Roedy Green
    Jan 24, 2006
  3. Alex Hunsley
    Replies:
    4
    Views:
    3,462
    Tim Williams (gmail)
    Jun 29, 2004
  4. ecureuil

    use Net::SMTP::Multipart;

    ecureuil, May 21, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    152
  5. Replies:
    1
    Views:
    400
Loading...

Share This Page