The result when these two strings are compared depends on whether a string or integer comparison is being performed. : Casting « Data Type « Perl






The result when these two strings are compared depends on whether a string or integer comparison is being performed.

   

$result = "123" < "45";  #the strings 123 and 45 are converted to integers, and 123 is compared to 45. 
$result = "123" lt "45"; #123 is alphabetically compared to 45. 

   
    
    
  








Related examples in the same category

1.Concatenating a number and a string
2.Adding number to a string
3.String is converted to a number automatically
4.How Strings Are Converted to Numbers
5.What happens if we try and join a number to a string?
6.Converting Strings to Numbers
7.String (with digits) is converted to number during the math operation
8.String (without digits) is converted to number during the math operation