[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] silly warnings



Wow, did I stump all the Perl experts, or did everyone go on vacation? ;-)
 
Another thought I had: Is it possible to "define $hash{$key}" manually without assigning a value to it?  (i.e. the opposite of "undef $hash{$key}")
 
Dan
On Tue, Jan 13, 2009 at 9:07 AM, Dan Linder <dan@linder.org> wrote:
Jay Hannah <jay@jays.net> wrote:
> next if ($audit->{$date} && $audit->{$date}->{$hotel} && $audit->{$date}->{$hotel} > 0);

Sterling Hanenkamp wrote:
> I usually prefer:
> next if ($audit->{$date}{$hotel} || 0) > 0;

Ok, I'm getting a similar issue with this bit of code:
55            } else {
56                ($value, $parm)=split(/\s+/,$line,2);
57                $myhash1{$section_name}{$parm} = $value;
58            }

Line 57 is spitting a lot of "Use of unitialized value in hash element" warnings -- I'm pretty certain it's because of the newly defined %myhash1 hash instantly having the $section_name and $parm keys used right away.

I tried putting in these lines between 56 and 57:
55            } else {
56                ($value, $parm)=split(/\s+/,$line,2);
57                ($myhash1{$section_name} || 0);
58                ($myhash1{$section_name}{$parm} || 0);
59                $myhash1{$section_name}{$parm} = $value;
60            }
...but the warnings still persist.

Aside from turning off warnings for these lines, is there a better way to handle this?  Should I be pre-loading the "$myhash1{$section_name}" branch first before adding the "{$parm}" branch to it?

Dan

--
"Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author)
** *** ***** ******* *********** *************



--
"Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author)
** *** ***** ******* *********** *************