in reply to Use of uninitialized value errors

Although I think your attempt is excellent, I will comment on the "uninitialized variable" warnings you get. This is happening because wherever you have a conditional based on a variable that may not contain a value, or even just printing a non-initialized variable will produce this warning. You may want to look at the lines that the warnings are producing and looking at every variable to see if it does actually contain a value. Here's a simple test:
if ($var) { print "\$var contains $var"; } else { print 'no content in $var'; }

I know its simplistic but it will certainly help, testing as I've found is very important. It saved me from a 14 GB error log!

BlackJudas

Replies are listed 'Best First'.
Re: Re: Use of uninitialized value errors
by dvergin (Monsignor) on May 17, 2002 at 00:04 UTC
    "This is happening because wherever you have a conditional based on a variable that may not contain a value"

    Nope. Perl forgives you if you simply test or assign a bare uninitialized variable in a conditional. Your code works for this reason -- no warning for "if ($var)". Going over your post, I think this is a case where you understand but just mis-stated your assertion.

    Note:

    #!/usr/bin/perl -w use strict; my $stuff; # No complaint here if ($stuff) { print "hello\n"; } # No complaint here if (my $stuff2 = $stuff) { print "hello\n"; } # But this interpolation causes a warning if (my $stuff3 = "$stuff") { print "hello\n"; } # This concatenation complains also if (my $newstuff = "new $stuff") { print "hello\n"; }

    ------------------------------------------------------------
    "Perl is a mess and that's good because the
    problem space is also a mess.
    " - Larry Wall

      True dvergin I was simply saying that if you make any decisions based on what a variable contains, if that variable is undefined, then perl will complain. But thank you for bringing that up!

      BlackJudas