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


i've been using code check if string empty:

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

and same not equals operator...

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

this seems work (i think), i'm not sure it's correct way, or if there unforeseen drawbacks. doesn't feel right it.

for string comparisons in perl, use eq or ne:

if ($str eq "") {   // ... } 

the == , != operators numeric comparison operators. attempt convert both operands integers before comparing them.

see perlop man page more information.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -