I am using the Net::FTP module on ActiveState Perl 5.6, build 626, running on Windows NT4 Workstation. I am attempting to put a file out on several of my company's servers, and am having a few troubles. Here is the code I am using at the moment.
#!perl -w
use strict;
use Net::FTP;
my $Local="C:\\Winnt\\Profiles\\jlewis\\desktop";
my $File="cron.file";
my $key;
my $IP;
my $user="username"; # NOT the real username
my $pass="password"; # And DEFINITELY NOT
# the real password
my %Servers=("1"=>'128.37.37.201',
"2"=>'128.38.38.201',
"3"=>'128.39.39.201');
chdir($Local);
foreach $key(%Servers){
$IP="$Server{$key}";
chomp($IP);
my $FTP=Net::FTP->new("$IP");
$FTP->login("$user","$pass");
$FTP->ascii();
$FTP->put($File);
$FTP->quit;
}
I am getting the following errors when I run this:
Use of uninitialized value in string at line 20,cronftp.pl
Can't call method login on an undefined value at line 23,cronftp.pl
I know that this means the error that is causing it all is when I declare the variable $IP to be equal to the value of whatever hash key its currently looping through, but for the life of me, I can't figure out why its uninitialized.
Please just point me in the right direction, and I'll take it from there. Thanks
RedDog