Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Can't detect empty Hash from a MySQL table

by Corion (Pope)
on Dec 26, 2020 at 21:35 UTC ( #11125758=note: print w/replies, xml ) Need Help??


in reply to Can't detect Hash values that are empty

undef does not work the way you think it does:

if(undef($text)) { ...

This will always set a variable to undef. You likely want defined as in if( ! defined($text)) { ...:

foreach my $row (@{$data_all}) { say $row; my %currec = %{$row}; foreach my $columns (keys %currec) { my $text = $currec{$columns}; say $text; if(! defined ($text)) { say "$columns is NOT DEFINED"; } elsif (length($text) < 1) { say "$columns DEFINED, but empty"; } } exit; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11125758]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2021-03-08 02:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (123 votes). Check out past polls.

    Notices?