drw has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Initialized Variable getting Uninitialized Warning
by ikegami (Patriarch) on Feb 27, 2019 at 17:51 UTC | |
by drw (Novice) on Feb 27, 2019 at 18:17 UTC | |
by ikegami (Patriarch) on Feb 27, 2019 at 18:36 UTC | |
by drw (Novice) on Feb 27, 2019 at 19:51 UTC | |
|
Re: Initialized Variable getting Uninitialized Warning
by ikegami (Patriarch) on Feb 27, 2019 at 17:46 UTC | |
by drw (Novice) on Feb 27, 2019 at 17:49 UTC | |
by pryrt (Abbot) on Feb 27, 2019 at 18:15 UTC |