CGI File Upload Problem

Dave Cross davorg at gmail.com
Fri Aug 27 09:30:19 UTC 2004


On Fri, 27 Aug 2004 09:33:42 +0100, PFJ <paul at all-the-johnsons.co.uk> wrote:
> Hi,
> 
> > Here's the upload portion of the code. $fh is the file being uploaded that
> > came from the form.
> >
> >         if ($line=<$fh>) {  --> THIS IS THE LINE THAT IS HAVING A PROBLEM
> > UNDER FEDORA BUT WORKS UNDER RH9
> 
> To me, there looks like two things which aren't quite right here. Try
> 
> if ($line eq $fh)
> 
> and see what happens. For some reason, the <$fh> just doesn't look
> right. I could be completely wrong, but unless you've just put $fh in
> the <> for the purposes of this email, it's not hitting the right notes
> here.
> 
> I've seen plenty of CGI scripts go insane due to either incorrect logic
> or just parsing incorrectly. Using eq rather than = may help.

That's almost certainly not the problem. That is perfectly normal Perl
code. It means, read the next line of input from the filehandle $fh
and assign it to $line.

Only suggestion that I would make is that it would more often be written as

while ($line = <$fh>)

but it's quite possible that earlier code will have put Perl into
"slurp mode" so that the whole file is read in on that one call.

As for the original problem, it's impossible to be much help without
seeing the whole program - or, at least, a cut down program that
exhibits the problem.

Dave...





More information about the fedora-list mailing list