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

In reply to Net::FTP troubles by RedDog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.