Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a problem with arrays and undeffing i think
by kvale (Monsignor) on Jun 17, 2002 at 02:58 UTC | |
|
Re: a problem with arrays and undeffing i think
by graff (Chancellor) on Jun 17, 2002 at 02:59 UTC | |
by Anonymous Monk on Jun 17, 2002 at 05:49 UTC | |
by graff (Chancellor) on Jun 19, 2002 at 02:09 UTC | |
|
Re: a problem with arrays and undeffing i think
by greenFox (Vicar) on Jun 17, 2002 at 10:49 UTC |