hi. i've wrriten an ftp program that every hour with check a directory for files and if there are any it will upload them then move them to a different folder. i get the file list like this.....

tie %Dir, IO::Dir, "p:/charts/Sendtray/." or &WriteToListView2("Error opening directory: $!");


foreach (keys %Dir) { unless ($_ eq "." or $_ eq ".." or $_ eq "GONE" or $_ eq "") { push(@FileList,$_); } }

then upload then move.

the first time the files are uploaded everything works fine. when it uploads a second time i keep on getting bad file descriptor errors with a space instead of a file name. because i can't remove the files from @FileList because they're uploaded in a foreach loop, i undef them after they're uploaded and moved....

foreach $oFile(@FileList) { if ($oFTP->put("p:/charts/Sendtray/$oFile")) { if (move("p:/charts/Sendtray/$oFile","p:/charts/Sendtray/G +ONE/$oFile")) { &LogSentFiles($oFile); $oFile = undef; } } }

so i figure the error is because of the undef working unlike how i expect it to. does anyone now how to stop this from happening?

Edit kudra, 2002-06-17 Added code tags to one paragraph per ntc request, line to try to preserve author's intent of keeping the two code bits apart


In reply to a problem with arrays and undeffing i think by Anonymous Monk

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.