in reply to Re: Checking Variable for Not Null
in thread Checking Variable for Not Null

Hi, what i mean by null in this case is i'm checking a date position in a file (for example position 140-148). If there is no date passed:

$ex_date=substr($_,140,8);$ex_date =~ s/\s+$//;

then i would want to skip to the next record.

Replies are listed 'Best First'.
Re^3: Checking Variable for Not Null
by Athanasius (Archbishop) on May 27, 2015 at 15:17 UTC

    In that case, your “null” corresponds to the empty string, so you can test for true or false (because the empty string is “false” in Perl):

    next if !$ex_date;

    But it’s better (because clearer) to make the test explicit:

    next if length $ex_date == 0; # or next if $ex_date eq "";

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Yes, thank you. that's a big help.