What is the proper way to check if a string is empty in Perl?

后端 未结 6 1894
日久生厌
日久生厌 2020-12-25 09:18

I\'ve just been using this code to check if a string is empty:

if ($str == \"\")
{
  // ...
}

And also the same with the not equals operato

6条回答
  •  滥情空心
    2020-12-25 09:55

    As already mentioned by several people, eq is the right operator here.

    If you use warnings; in your script, you'll get warnings about this (and many other useful things); I'd recommend use strict; as well.

提交回复
热议问题