Converting Strings to Numbers : Casting « Data Type « Perl






Converting Strings to Numbers

   

#!/usr/bin/perl

use warnings;
print"12 ABC" + 0, "\n";
print "Eleven to fly" + 0, "\n";
print "acB40" + 0, "\n";
print "-20 10" + 0, "\n";
print "0x30" + 0, "\n";

   
    
    
  








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.The result when these two strings are compared depends on whether a string or integer comparison is being performed.
7.String (with digits) is converted to number during the math operation
8.String (without digits) is converted to number during the math operation