The program creates some pages from a database, saves them locally, then uploads them to a remote server. The program takes a few seconds to run. After it exits, one file is always empty on the remote server. It is not empty on the local system.
(Apologies for any errors in transcription. This is a logic bug, not a typo.)my @built; my @files = get_files_to_build(); for (@files) { my $built = build_file($_); unless ($built) { warn "Could not build $_!\n"; next; } my $filename = File::Spec->catfile($path, $_); open(OUTPUT, "> " . $filename) or die "Can't open $filename: $!"; print OUTPUT $built; push @built, [ $filename, $_ ]; } my $ftp = Net::FTP->new($remotehost, Debug => 1) or die "Can't connect to $remotehost: $@\n"; $ftp->login($username, $password) or die "Couldn't authenticate!\n"; $ftp->cwd('www'); foreach my $updated (@built) { my ($location, $name) = @$updated; $ftp->put($name, $location) or warn "Couldn't put $name: $@\n"; } $ftp->quit();
There are I came up with four possible solutions. One is very easy, the second works implicitly. The third may not work on every platform, and the fourth is crazy.
I'm including a couple of hints in HTML comments. I know several saints who would pick this out right off the bat, but let's leave this for people who don't normally speak up.
Hints follow.
Update: So far, ZZamboni and Albannach have both caught it. Good job! arturo also got it right, pointing out a legitimate typo that wasn't the bug. Then Spudnuts sent me a /msg, and I decided it would be okay for people to post their own answers. It might be good to stick them in HTML comments (<!-- comment here -->), though. So far no one's provided anything but the first and most direct fix.
tilly spotted two other typos and came up with four fixes. Abigail also gets a gold star, but if either of those two are novices, I'm secretly Jon Orwant.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Novice Quiz: File is created locally, uploaded empty
by Abigail (Deacon) on Jun 22, 2001 at 04:52 UTC | |
by tilly (Archbishop) on Jun 22, 2001 at 05:04 UTC | |
by John M. Dlugosz (Monsignor) on Jun 23, 2001 at 01:09 UTC | |
by Abigail (Deacon) on Jun 25, 2001 at 19:08 UTC |