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

if ($_ =~ /^$/)

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

Perhaps this would work better:

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