cgi_error has asked for the wisdom of the Perl Monks concerning the following question:

im usng a form to try and upload files with cgi ftp program the command to upload that im using is,
$ftp->put($files);

and the file.
my $files = $in{'file1'};

$in{'file1'} is the form input (aka the name of the field with the file to be uploaded), ok so u get what i mean. this is teh error im getting

Global symbol "%in" requires explicit package name at D:\bujo\cgi-bin\upload\upload.cgi line 34.

and line 34 is below
my $files = $in{'file1'};

so how do i fix this? how do i get the value of the file to be uploaded from a form, if i just used a normal variable like $file = "fullpathtofiletoupload"; it would work, but if i try and get the file from a form it dosnt work.

grateful for any help
Thanks, Dlema

Replies are listed 'Best First'.
Re: ftp uploading
by Corion (Patriarch) on Nov 08, 2001 at 15:51 UTC

    The error you are getting is reported by the strict module, which traps a lot of silly mistakes. What strict wants to tell you is that the variable %in is used in your script before you have declared it with my %in;. Either you have misspelled the variable name (maybe %In ?) or you haven't initialized that variable at all.

    You should either post a bigger snippet of your code (or all of your code if you can reduce the problem to below 50 lines), or at the very least, describe in a bit more detail how you fill %in and where you declare it.

    For example, the following code will create an error similar to your error even though you do declare %in (but in the wrong place) :

    use strict; sub read_CGI_Variables { my %in; # Win32/DOS allows forward slashes ! $in{"file1"} = "c:/uploads/myfile.tmp"; }; read_CGI_Variables(); print "Uploaded ",$in{"file1"},"\n";
    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: ftp uploading
by Aristotle (Chancellor) on Nov 08, 2001 at 16:28 UTC
    What are using to parse the CGI request? If it's the CGI module, your problem is that it doesn't produce an %in hash for you by default, it has to be asked to. I also suspect you're oversimplifying the problem there - so I agree with the above reply: post some more of your code.