in reply to Re^2: Checking for blank string
in thread Checking for blank string

Hi Himaja,

still getting the waring mentioned above.

The data you showed doesn't contain any undefs, and the if statement looks correct to me, so the warning must be coming from some other undef value somewhere else in your code. The best thing would be if you could show a Short, Self Contained, Correct Example that reproduces the problem (see also How do I post a question effectively? and Basic debugging checklist).

Regards,
-- Hauke D

Replies are listed 'Best First'.
Re^4: Checking for blank string
by choroba (Cardinal) on Sep 26, 2016 at 09:52 UTC
    > so the warning must be coming from some other undef value somewhere else in your code

    Maybe the key doesn't exist in the hash at all?

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      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