If only...

		if ($garfield == 6) {
			print "Garfield is most definitely six\n";
		}
  • What does it mean to be true? Here are some examples of things Perl thinks are true:
  • 		$popcorn = 10;
    
    		if ($popcorn == 10) { }
    
    		if ($popcorn < 15) { }
    		if ($popcorn != 1) { }
    		if ($popcorn eq "10") { }
    		if ($popcorn = 15) { }			#Huh?
    
    		$behavior = "music";
    		if ($behavior eq "music") { }
    		if ($behavior = "mon ami") { }	#Same as last odd one...
    		if ($behavior =~ /music/) { }   #Huh?
    		if (length($behavior == 5) { }  #What?
    
    
    		if ($popcorn == 5) { }
    
    		if ($popcorn eq "dancing") { }
    		if ($behavior ne "music") { }
    
    
    		if (1) { }  #True!
    		if (0) { }  #False!
    
    
    
    		$popcorn = 10;
    
    		if ($popcorn == 15) {
    			print "Popcorn is 15";
    
    		}
    
    		else {
    
    			print "What?  Popcorn isn't 15??";
    
    		}