title: Program to send mail won't compile
body: <pre><code>use strict;
  use warnings;
  
  use Net::SMTP;
  
  # to install Net::SMTP moudle package, run cpan command in command line
  # in the shell type install Net::SMTP
  
  sub send_mail
  ####################################################################################################
  #
  # SUBROUTINE : send_mail
  #
  # PURPOSE    : Send an email.
  #
  # INPUT(S)   : smtp_server - Simple Mail Transfer Protocol server
  #              to          - Recipient address
  #              from        - Sender address
  #              subject     - Subject
  #              body        - Reference to an array containing the message body
  #
  # OUTPUT(S)  : 0 - success
  #              1 - failure
  #
  ####################################################################################################
  {
  
  
       my $from    = 'home.yosef@gmail.com';
       my $to      = 'home.yosef@gmail.com';
       my $data    = "A simple test message from Perl script\n";
       my $subject = "Hello World from Perl script";
  
       smtp_server =&gt; "smtp.gmail.com";
  
  
  
      # Connect to the SMTP server
      my $smtp = Net::SMTP-&gt;new($smtp_server);
  
      # If connection is successful, send mail
      if ($smtp) {
  
          # Establish to/from
          $smtp-&gt;mail($from);
          $smtp-&gt;to($to);
  
          # Start data transfer
          $smtp-&gt;data();
  
          # Send the header
          $smtp-&gt;datasend("To: $to\n");
          $smtp-&gt;datasend("From: $from\n");
          $smtp-&gt;datasend("Subject: $subject\n");
          $smtp-&gt;datasend("\n");
  
          # Send the body
          $smtp-&gt;datasend(@body);
  
          # End data transfer
          $smtp-&gt;dataend();
  
          # Close the SMTP connection
          $smtp-&gt;quit();
  
      # If connection fails return with error
      }
      else {
  
          # Print warning
          warn "WARNING: Failed to connect to $smtp_server: $!";
  
          return 1;
      }
  
      return 0;
  }
  
  # Define the message body
  my @message_body = "Hello World! from Perl script\n";
  push @message_body, "Add another line!\n";
  
  # Send the email!
  send_mail(
      smtp_server =&gt; &lt;smtp_server_name&gt;,
      to          =&gt; &lt;to_address&gt;,
      from        =&gt; &lt;from_address&gt;,
      subject     =&gt; 'This is a mail from Perl script',
      body        =&gt; \@message_body,
  );
  </code></pre>
  
  <p>I have Windows installed with Strawberry Perl. When I run this script from the command line I get errors and I donn't know what is wrong.</p>
  
  <p>These are the errors:</p>
  
  <blockquote>
    <p>Global symbol "$smtp_server" requires explicit package name (did you forget to declare "my $smtp_server"?) at windows_send_mail_with_SMTP.pl line 40.<br>
    Global symbol "@body" requires explicit package name (did you forget to declare "my @body"?) at windows_send_mail_with_SMTP.pl line 59.<br>
    Global symbol "$smtp_server" requires explicit package name (did you forget to declare "my $smtp_server"?) at windows_send_mail_with_SMTP.pl line 71.<br>
    Execution of windows_send_mail_with_SMTP.pl aborted due to compilation errors.  </p>
  </blockquote>