title: Global symbol "$line" and "$addr" requires explicit package name
body: <p>I'm trying to get the output to show a list of ip addresses and login with the corresponding country but I keep getting these errors: Global symbol $line and $addr requires explicit package name. It works fine in Perl but I'm running this script from the server. Anyone have any ideas? Thanks.</p>
  
  <pre><code>#!/usr/bin/perl
  
  my $psql = "/usr/local/pgsql/current/bin/psql";
  my $db = 'cpi';
  my $args = "-U postgres -qc";
  
  my $date = `/bin/date +\%y\%m\%d%H`;
  my $reportfile = "/tmp/multiiplogins-$date";
  
  my $sendmail = "/usr/sbin/sendmail -t -fcpi\@cpi-syndication.com";
  my $mailsubject = "Login Report";
  my $mailto = 'user@yahoo.com';
  
  my $query = "SELECT userid, login, email, logins, ips FROM (SELECT userid,login,email,       count(userid) AS logins, count(ipaddr) AS ips FROM (SELECT l.userid, u.login, u.email$
  
  my $query2 = "SELECT l.userid, login, email, ipaddr FROM synloginaccess l, synusers u where l.accesstime &gt; (now() - interval '24 hours') and l.type=2 and l.userid=u.userid $
  
  open (REPORT, "&gt;$reportfile");
  
  my $command = qq/$psql $db $args "$query"/;
  my $command2 = qq/$psql $db $args "$query2"/;
  
  my $result = `$command`;
  my $result2 = `$command2`;
  
  #update IP addresses with country
  use strict;
  use warnings;
  use Net::IPInfoDB;
  
  my $g = Net::IPInfoDB-&gt;new;
  $g-&gt;key("api_key");
  
  #we split $login into an array, line-by-line
  my @lines = split("\n",$result2);
  for my $line (@lines) {
     #now we iterate through every line one-by-one
     $line =~ /(?&lt;ip&gt;\d+\.\d+\.\d+\.\d+)/;
     my $addr = $g-&gt;get_country("$1");
     print "$line " . "| ". "$addr-&gt;country_name" ."\n";
  
   }
  
  
      #print REPORT "$result2\n";
      #print REPORT "\n";
      print REPORT "$line " . "| ". "$addr-&gt;country_name" ."\n";
  
    close REPORT;
    mailReport();
  
   sub mailReport{
       #mail it
       open(MAIL, "|$sendmail");
       print MAIL "To: $mailto\n";
       print MAIL "Subject: $mailsubject\n";
       print MAIL "\n";
       open (INFILE, "$reportfile");
       my @contents = &lt;INFILE&gt;;
  </code></pre>