Perl error: Use of uninitialized value in numeric eq (==)

Discussion in 'Programming' started by chrisj, Dec 11, 2015.

  1. #1
    Can someone help me with this error:

    [Fri Dec 11 12:07:24.417565 2015] [cgi:error] [pid 10838] [client 24.32.36.240:54536] AH01215:  [Fri Dec 11 12:07:24 2015]
    uu_upload.pl: Use of uninitialized value in numeric eq (==) at uu_upload.pl line 350.:  /home/public_html/cgi-bin/uu_upload.pl,
    referer: http://www.....com/uploader.php
    Code (Perl):
    Line 349 - Line 353 shows:

        # Force 'redirect_using_location' if user does not have a javascript capable browser or using embedded_upload_results
    if($query->param('no_script') || $query->param('embedded_upload_results') == 1){
        $main::config->{redirect_using_js_html} = 0;
        $main::config->{redirect_using_location} = 1;
    }
    PHP:
    Any help will be greatly appreciated.
     
    chrisj, Dec 11, 2015 IP
  2. Webpass.io

    Webpass.io Member

    Messages:
    8
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    33
    #2
    I don't use Perl, but it looks like there is no value "$query->param('embedded_upload_results')", so it can't compare it to 1. Note that it's saying that there's an uninitialized value. Perhaps you could try:

    
    if($query->param('no_script') || ($query->param('embedded_upload_results') && $query->param('embedded_upload_results') == 1))
    
    Code (Perl):
    That then checks first that the embedded_upload_results is initialized before checking if it is equal to 1. Typically, if a language faces something like "A && B", and it turns out that not-A, it won't bother evaluating B because it already knows that the statement is false.

    As mentioned, I don't use Perl, so I haven't tested whether this will work.
     
    Webpass.io, Dec 11, 2015 IP
    deathshadow and NetStar like this.
  3. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #3
    Perl use to be my favorite language for Web Development. Even when everyone jumped ship to use PHP, Python and Ruby I stayed loyal to Perl......until I opened my eyes. None of the libraries in CPAN were being maintained or growing... even the projects for frameworks and *ahem* "Perl6" were never complete. Then I left Perl... Perl6 has been in "development" for over a decade. That should be indication that the community isn't there anymore! While I'm STILL an advocate of Perl I would NEVER EVER suggest using it for Web Development in 2015/2016. If you have to ask such an elementary question on a forum then it is NOT too late to switch over to a language that was built for the web with a LARGER more active community with active UPDATED libraries and projects. If you want an easy transition look at PHP.
     
    NetStar, Dec 13, 2015 IP
    deathshadow likes this.
  4. Karim Nasser

    Karim Nasser Greenhorn

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    18
    #4
    You have to initialize values before you use them / compare them.
    So I would suggest the following:

    my $ns = $query->param('no_script') || '';

    This ensures that $ns has either a parameter value, or blank if nothing is passed. You can assign anything that makes sense ('', 0, ...)
    Then use $ns to do your comparison (==)

    Do the same for other parameters.
     
    Karim Nasser, Jul 31, 2016 IP