while loop - How do I detect an empty line from input or a file in Perl? -


while ($_ ne ' \n') doesn't detect if input empty line , loop indeterminately in while. why?

depends mean "an empty line".

does line contain no characters other newline?

if ($_ eq "\n") # note, \n means newline in double quoted string. 

or

if (/^$/) 

does line contain whitespace characters

if (/^\s*$/) 

but easier if invert logic line doesn't include non-whitespace characters

if (! /\s/) 

one of should want.


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -