Edit: Solution found, thank you ikegami!

I am having consistent issues with an "uninitialized" value warning in my script, and I can't seem to identify the problem:

package EcomAllcancel; use warnings; use strict; use lib "./feedmodules"; use EcomImportUtilities; sub execute { my $biuw = shift; my $TABLE = 'ecom_allcancel'; my $FILE = 'cmdaycan.data'; my $PATH = "$biuw->{yml}{filepath}/orderinfo/"; my $table_summary = $TABLE . '_summary'; my $DATE_COLUMN = 'date_cancel'; my $ALLOWED_CHANGE = $biuw->{yml}{allcancel_allowed_change}; my $temp_table = $TABLE . '_temp'; my $feedfullpath = $PATH . $FILE; $biuw->{log}->info("\n\n**********\nBegin $TABLE load sequence\n** +********\n\n"); my $exception = EcomImportUtilities::ageCheck( biuw => $biuw, feedpath => $feedfullpath, tablename => $TABLE ) unless $biuw->{const}{load_old}; if ($exception->{exception} eq 'outofdate' or $exception->{excepti +on} eq 'stillcopying') { $biuw->{log}->warn("$feedfullpath is out of date. Loading stop +ped.\n"); return $exception; } elsif ($exception->{exception} eq 'nonexistent') { $biuw->{log}->warn("$feedfullpath does not exist. Loading stop +ped.\n"); return $exception; }

This is simply the beginning of the code. The $exception hash is loaded into a subroutine on another module, which will return a hash that looks like this:

my $exception = { table => $tablename, exception => 'nonexistent', data => { file => $filepath, age => 0, nonexistent => 1 } }; return ($exception); }

I keep getting errors stating that there is "Use of uninitialized value in string eq" at line 34, 34 and 39. From what I can gather, it is referring to the "$exception->{exception}" references, but I can't seem to figure out why this is causing the issue. I declared the $exception, and the $exception->{exception} is declared in the subroutine module. Why would it still be coming back as "uninitialized"?

So far I have tried simply adding a line to the hash (exception => '' / exception => undef) or declare it separately (my $exception{exception};) but the warning persists. I am clearly overlooking something that should be obvious, but I can't figure this one out.


In reply to Initialized Variable getting Uninitialized Warning by drw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.