Hi choroba,
Maybe the key doesn't exist in the hash at all?
The defined check would still catch that and there wouldn't be a warning. And if $cell was undef, the warning would be "Use of uninitialized value $cell in hash element", not "Use of uninitialized value $data in string eq" as the OP posted here.
use warnings; use strict; my $sheet = { 'X92' => '', 'AA571' => '0.00', 'AA842' => '0.00', 'B6' => '0', 'E47' => 'SRAM (ssbw)', 'M83' => '', 'X55' => undef, 'B29' => '0' }; sub test { my $cell = shift; if(defined $sheet->{$cell} && length($sheet->{$cell})) { print "Yes\n" } else { print "No\n" } } test(undef); test('A12'); test('X55'); test('M83'); test('B29'); test('E47'); __END__ Use of uninitialized value $cell in hash element at ... No No No No Yes Yes
Regards,
-- Hauke D
In reply to Re^5: Checking for blank string
by haukex
in thread Checking for blank string
by Himaja
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |