Apparently inconsistent behavior in a CGI program
> [I have no clue whether the problem is with my use of CGI.pm, my use
> perl, or my use of my brain, so I didn't set follow-up - feel free to
> point it to whichever group you think is best-suited]
> Short problem description:
> This script uploads a file to a per-user directory on the server, and
> chmods it to 644 if it didn't already exists. It then displays one of
> two messages, depending on whether the file existed. Or rather, it
> should display... What happens instead is that it will only display
> "replaced" message. When it should display the 'created" message, it
> will do nothing, although the file is still saved in the right
> I can't see any difference that would explain it, and it doesn't seem
> be related to the OS, Apache/CGI.pm version, or browser, as it was
> tested under several combos with essentially the same results.
AFAICT there's nothing wrong with your script. I made one change to the
example you had in that I wasn't running with taint mode (-T) on - I
just set the destination dir to something writable by my webserver user.
Is there anything in apache's error-logs? You seem to be checking all
your system-calls' return values, so if your script is die-ing there
should be something there.
Oh, and there *is* a file being uploaded isn't there - the only thing
you don't seem to check is that $file is set.
- Richard Huxton