Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

use of uninitialised value

by Anonymous Monk
on Mar 07, 2005 at 18:28 UTC ( #437280=perlquestion: print w/replies, xml ) Need Help??

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

i am getting this error amd i dont know how to handle this its not recognizinf the open() function and gives me the error Use of uninitialized value in concatenation (.) or string my open(0 statement in the program is open (UPLOADFILE,"<$upload_dir/$filename") or die $!;

Replies are listed 'Best First'.
Re: use of uninitialised value
by Joost (Canon) on Mar 07, 2005 at 18:32 UTC
Re: use of uninitialised value
by friedo (Prior) on Mar 07, 2005 at 18:32 UTC
    Perl optimizes things like "$upload_dir/$filename" to $upload_dir . '/' . $filename, which is why the warning is complaining about the concatenation operator. One of those variables is not initialized. Try printing them to see which one it is. You've probably got a typo somewhere. If one of them is supposed to be empty in some circumstances, make sure it's set to the empty string ("") instead of remaining uninitialized.
Re: use of uninitialised value
by sh1tn (Priest) on Mar 07, 2005 at 19:08 UTC
    IMHO you should check "what's behind" -
    -d $upload_dir or die "$upload_dir: $!"; -f $filename or die "$filename: $!"; # if we are here - we have valid directory and file open (UPLOADFILE,"<$upload_dir/$filename") or die $!;

      That would need to be:
      -d $upload_dir or die "$upload_dir: $!"; -f "$upload_dir/$filename" or die "$upload_dir/$filename: $!";
        Thank you. My error comes from the lack of fully written sample:
        my $filename = "$upload_dir/$filename"; -d $upload_dir or die "$upload_dir: $!"; -f $filename or die "$filename: $!"; # I'm not in the secret why those endless absolute # filepaths are scattered almost always

Re: use of uninitialised value
by hok_si_la (Curate) on Mar 07, 2005 at 18:36 UTC

    My guess is that you are getting that warning from not declaring a scalar that is being used. Perhaps you did not declare $upload or $filename. This would explain both the warning, and the problem opening the file.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://437280]
Approved by Joost
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2021-11-28 17:33 GMT
Find Nodes?
    Voting Booth?

    No recent polls found