in reply to Re^2: Checking for blank string
in thread Checking for blank string

In that case, your $data really is undefined. I would rewrite your statement like this:

next unless defined $data;

TIMTOWTDI, of course.