in reply to How to check if an array element reference exists or not

if( $row[7] ){ ... or if( defined $row[7] ){ ...

See also perlintro/perlsyn

Replies are listed 'Best First'.
Re^2: How to check if an array element reference exists or not
by corpx (Acolyte) on Apr 14, 2010 at 08:52 UTC
    I tried both those cases, but they always return false and the print statement never gets executed, even when such a cell exists.

      So, how do you determine that "such a cell exists"? I recommend printing your data structure:

      use Data::Dumper; print Dumper $row;

      That will show you whether such a cell exists in $row. Maybe it's the 7th cell, which would be at $row->[6]. Usually, when Perl says that defined $row->[7] is false, Perl is right.

        Thanks for the reply. Maybe these screen shots of the debugger will explain my question. With if ( defined $row[7] ) and if ( $row[7] ), neither returns true in the case of the second screen shot.