[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

03/09/2004 at 04:25AM PST, ID: 20912237
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

Determining if a file exists (PERL)

Asked by DavidLeeding in CGI Scripting

Tags: perl, file, exists

Hi

Although I have a background in programming, PERL is completely new to me...and I'm getting nowhere fast!! Hoping you can help!

I have obtained a PERL script that is used in conjunction with a web form to upload a customer's file (or files) to a server. The script is working perfectly except for one flaw...if the user's file does not exist locally (eg the user typed an invalid file name), the script still acts as though the file *was* uploaded successfully. In fact, it creates a zero-length file on the server, and reports to the user that the file was uploaded.

Ideally, I'd like the script to fail gracefully if the filename does not exist locally.

Can this be done???

The following is an extract of the script to give you some context. I have marked the area where I think (?) the appropriate test would go (assuming there is something that can be done).

$ERROR_BADFILE = "/ord_err1.htm";
$SAVE_DIRECTORY = "/home/usrname/www/orders";
...
$| = 1;
chop $SAVE_DIRECTORY if ($SAVE_DIRECTORY =~ /\/$/);
use CGI qw(:standard); # Script uses CGI.pm
$query = new CGI;

foreach $key (sort {$a <=> $b} $query->param()) {
    next if ($key =~ /^\s*$/);
    next if ($query->param($key) =~ /^\s*$/);
    next if ($key !~ /^file-to-upload-(\d+)$/);
    $Number = $1;
            
    if ($query->param($key) =~ /([^\/\\]+)$/) {
        $Filename = $1;
        $Filename =~ s/^\.+//;
        $File_Handle = $query->param($key);

#### --> Test in here? if ( ! (file exists locally)) {
####       redirect to error page (ie $ERROR_BADFILE)
####       then exit

    } else {
        print $query->redirect($ERROR_BADFILE);
        exit;
    }

Hoping someone can enlighten me!!

Thanks

David
[+][-]03/09/04 05:05 AM, ID: 10549722

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/09/04 12:36 PM, ID: 10554354

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/09/04 02:26 PM, ID: 10555473

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/09/04 04:08 PM, ID: 10556244

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/09/04 04:27 PM, ID: 10556396

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/10/04 07:03 AM, ID: 10561199

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/11/04 02:54 AM, ID: 10569931

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/11/04 02:57 AM, ID: 10569954

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/11/04 03:01 AM, ID: 10569975

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/15/04 02:50 PM, ID: 10601867

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/15/04 03:39 PM, ID: 10602136

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/07/04 09:55 PM, ID: 11256626

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: CGI Scripting
Tags: perl, file, exists
Sign Up Now!
Solution Provided By: Netminder
Participating Experts: 6
Solution Grade: B
 
 
[+][-]06/07/04 09:55 PM, ID: 11256629

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091028-EE-VQP-85