dakedesu has asked for the wisdom of the Perl Monks concerning the following question:
I humbly ask the monks greater than me about an error that has been giving me much humility. While humility is fine in some cases, it is not good when your trying to get some thing done...
What I want the snippet of code, that currently is not working, to do is check to see if the user of the upload has a directory on the server, and if they do not, make them one...
The syntax error is: Compilation failed in require at e:\domains\karawachi.com\user\htdocs\upload\default.pl line 13
The code in that file main file (default.pl) is:
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); push @INC, "e:/domains/karawachi.com/user/htdocs/upload"; package S3DUpload; my $basedir = "e:/domains/karawachi.com/user/htdocs/upload/upload"; my $stylefile = "style/style1.css"; my $datfile = "dat/datfile.dat"; # This next line is where the error: # Compilation failed in require at e:\domains\karawachi.com\user\htdoc +s\upload\default.pl line 13. # Prolly now line 16 or something in this text. require "checkname.pl"; require "displayfiles.pl"; require "handleupload.pl"; require "parsedatfile.pl"; require "printdat.pl"; require "uploadscreen.pl"; require "welcome.pl"; require "upload.pl"; return 1;
I will take the package bit out, maybe, later.
The code in the other file (checkname.pl) is:
#!/usr/bin/perl use strict; use CGI; # Errors should get shown to the browser better here: use CGI::Carp qw(fatalsToBrowser); # checks to see if a user has a directory, # Then makes one if they do not... sub checkname { $name = shift; opendir UPLOAD,"$basedir/$name" or mkdir "$basedir/$name", 777; closedir UPLOAD; #return success, cause you should always have # a return'd value return 1; } # Need this line so that the file may be # gotten with require(); return 1;
Unless I am being evil with my opening of directories (Which I think would cause an error when the function is actually used more than anything), this code should work. Of course I am not really seasoned enough in perl to make that as an accurate judgement.
DakeDesu teh Confused Werewolf.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with require()
by dws (Chancellor) on Dec 19, 2001 at 06:49 UTC | |
by chip (Curate) on Dec 19, 2001 at 12:09 UTC | |
by dakedesu (Scribe) on Dec 19, 2001 at 06:53 UTC | |
by dws (Chancellor) on Dec 19, 2001 at 06:59 UTC | |
by dakedesu (Scribe) on Dec 19, 2001 at 07:03 UTC | |
|
Re: Problem with require()
by joealba (Hermit) on Dec 19, 2001 at 10:47 UTC |