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

hi all,

i am very new to perl programming. i got an error when running a perl script which uses certain numbers of perl modules.

below are the errors i got:

Use of uninitialized value in concatenation (.) or string at /usr/local/share/perl/5.10.0/Schedg/MyFiler.pm line 50, <FH> line 73260.

Use of uninitialized value in print at /usr/local/share/perl/5.10.0/Schedg/Filer.pm line 262, <FH> line 73260.

the files can be download from another forum: http://perlguru.com/gforum.cgi?post=38524;#38524

thanks.

Replies are listed 'Best First'.
Re: Errors in some perl modules
by aufflick (Deacon) on May 29, 2009 at 14:15 UTC
    Those messages are not errors, they're warnings. They are both warning you that variables are being used before they are set to anything. Imagine something like:

    my $var1; my $var2; $var1 = "Something"; print $var1 . $var2;
    You can see that $var2 has not been set to anything. In Perl that is not an error, since an undefined value becomes a blank string in string context, but it is a pointer to sloppy coding or a mistake - hence why you get the warning when perl warnings are turned on.

    Update: Original had a typo where I said $var1 instead of $var2. Thanks to AnomalousMonk

      You may also be using

      #!perl -w

      instead of

      #!perl use warnings;

      The first turns on warnings in modules as well as in the main program. The second ignores, for better or worse, warnings in any included modules.

      --MidLifeXis

      The tomes, scrolls etc are dusty because they reside in a dusty old house, not because they're unused. --hangon in this post

      Those messages are not errors, they're warnings.

      Those messages are warnings and might not be errors.

      But in my experience, warnings almost always errors in Perl.

        But in my experience, warnings almost always errors in Perl.

        Yes, if only because it is an error to get warnings and not heed them... ;-)