However, the first command my $a ==<stdin>; does not assign to $a the value from stdin, since herecomparison operator "==" is used instead of "=" Moreover, in if/elseif/else statement it is usedNUMERICAL comparison operator "==" is used for comparing strings. In this case boths strings $a and "Pardeep" areconverted to zeros 0, and then these zeros are compared. As they are equal, ($a =="Pardeep") is true, and so the program prints "match"
If we'd use "eq" instead of "==": if($a eq"Pardeep") { print"match"; } elsif($a eq"pardeep") { print"ok" } else { print"not match"; }
then the output will be "not match"Ques 2:The print command print " $b"; will print the value of $b defined at line our $b = 7; since in true subroutine "first" the variable $bwith the same name is defined as "local" So the correct answer is b) 7
Comments
Leave a comment