in reply to Re^2: Uninitialized Value
in thread Uninitialized Value

Is there a way for the code to ignore the whitespace or any type of null in the data file?

while (<FILE>) { if ($_ =~ /^$/) { print "it's blank\n"; next; #process next line } else { print "it's NOT blank\n"; } }

if($_ =~ /^$/) can also be written as if(/^$/)


All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re^4: Uninitialized Value
by marinersk (Priest) on May 18, 2015 at 19:13 UTC

    if ($_ =~ /^$/)

    This code does not detect whitepace (a line of all spaces, for example) as requested.

    Perhaps this would work better:

    if ($_ =~ /^\s*$/)

Re^4: Uninitialized Value
by Not_a_Number (Prior) on May 18, 2015 at 20:07 UTC

    ...also, the next is unnecessary.