Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] SMTP /. ARRAY error

Expand Messages
  • Charles K. Clarkson
    ... From: Gordon Stewart To: Sent: Monday, November 26, 2001 9:32 PM Subject: [PBML] SMTP /.
    Message 1 of 1 , Nov 28, 2001
    • 0 Attachment
      ----- Original Message -----
      From: "Gordon Stewart" <Gordon.Stewart@...>
      To: <perl-beginner@yahoogroups.com>
      Sent: Monday, November 26, 2001 9:32 PM
      Subject: [PBML] SMTP /. ARRAY error


      : >>> cclarkson@... 11/26/01 11:52 >>>
      : >
      : Dump it.
      :
      : use Data::Dumper;
      :
      : print Dumper $mailcfg{smtp};
      :
      : ARRAY(0x176569c) is an array reference. Dumper should show
      : you what's inside.
      :
      : HTH,
      : Charles K. Clarkson
      : <
      :
      : Ok - Thanks...
      :
      : Now - in my Sendmail.pm file i have :-
      :
      : -------------------------------------
      : print "<BR><HR>5<BR>\n";
      : print Dumper $mailcfg{smtp};
      : print "<BR>\n";
      : foreach $server ( @{$mailcfg{'smtp'}} ) {
      : print "SERVER - $server - $mailcfg{'smtp'}<BR>\n";
      : }
      :
      : foreach $server ( @{$mailcfg{'smtp'}} ) {
      : # open socket needs to be inside this foreach loop on Linux,
      : # otherwise all servers fail if 1st one fails !??! why?
      : unless ( socket S, AF_INET, SOCK_STREAM, (getprotobyname 'tcp')[2] ) {
      : return fail("socket failed ($!)")
      : }
      :
      : -------------------------------------
      :
      : and the result is :-
      :
      : ---------------------------------------
      :
      : ------------------------------------------------------------------------------
      --
      : 5
      : $VAR1 = [ 'noadsm1.ird.govt.nz' ];
      : SERVER - noadsm1.ird.govt.nz - ARRAY(0x176569c)
      : Error sending mail: socket failed (Unknown error)
      : $Mail::Sendmail::log says: Mail::Sendmail v. 0.78 - Tue Nov 27 10:23:36 2001
      Date: Tue, 27 Nov 2001 10:23 +1300
      :
      : ---------------------------------------
      :
      :
      : So - When i print the 'dump' value - it holds the value i want / Need - of my
      Smtp thingee
      :
      : However, when I try & put
      :
      : ------------------------
      : print "<BR><HR>5<BR>\n";
      : print Dumper $mailcfg{smtp};
      :
      : $mailcfg{smtp}=Dumper $mailcfg{smtp}; ## <<<<<<<< changed
      :
      : print "<BR>\n";
      : foreach $server ( @{$mailcfg{'smtp'}} ) {
      : print "SERVER - $server - $mailcfg{'smtp'}<BR>\n";
      : }
      : ------------
      :
      : it displays an error message :-
      :
      : "Can't use string ("$VAR1 = [
      : 'noadsm1.ird") as an ARRAY ref while "strict refs"
      :
      : etc...
      :
      : How do i correct the error / Make it take the actual value ?
      :

      Dumper helps you see the object. When you printed it, you saw:
      $VAR1 = [ 'noadsm1.ird.govt.nz' ], which is an anonymous arrray
      with one value in it. To access each value (in this case, just 1), you
      dereference the array. In this case: @{ $mailcfg{smtp} } does the
      trick:

      print "<BR><HR>5<BR>\n";
      print Dumper $mailcfg{smtp};

      # $mailcfg{smtp}=Dumper $mailcfg{smtp}; ## <<<<<<<< changed

      print "<BR>\n";
      foreach $server ( @{$mailcfg{smtp}} ) {
      print "SERVER - $server - $mailcfg{smtp}<BR>\n";
      }

      The foreach block above is working fine. The error you're from
      sendmail is not due to this. I don't know enough about socket
      programming to help. Perhaps you could hop over to perlmonks
      and ask there.

      HTH,
      Charles K. Clarkson
      Clarkson Energy Homes, Inc.

      The only place you find success before work is in the dictionary.
      - May V. Smith
    Your message has been successfully submitted and would be delivered to recipients shortly.