in reply to Can you explain this error please?

  1. Yes, this is a warning. Warnings exist to alert you to potential problems. Not all warnings constitute actual critical bugs, but without investigation it's hard to know if a bug exists or not.
  2. You may remove "use warnings;", or better, declare "no warnings 'uninitialized';" in the narrowest possible scope. But this is almost always the wrong approach.
  3. Warnings are printed to STDERR. If you redirect STDERR to /dev/null you won't see any warnings, or error messages, or anything else printed to STDERR. This is probably the wrong approach. You could also define a $SIG{__WARN__} handler, which is also probably the wrong approach.

The right approach: Determine why $test is not initialized, and either fix that, or don't use it if it's not initialized. The warning is being generated because your code encountered a case that you didn't anticipate, which left $test empty. Wouldn't you agree it is better to discover what case you didn't anticipate, and fix your code to deal with such cases more gracefully?


Dave