I am trying to compare two variables in which are usually strings. These variables are generated from a database, $var1 from one db and $var2 from another. When I compare them in a loop I use the ne operator. However there are times when I these variables are null or undef. The comparison is done as follows:
foreach my $var1 (@$varlist)
{
if ($var1 ne $var2)
{
print "vars are not equal";
}
}
The issue is that if $var1 or $var2 are undef then I get an error. However, I need to be able to compare then values as undef b/c I will have to write them. I considered converting the variables to a string 'NULL' and then back but that seemed inefficient.
Any way to fix this? Thanks!
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)