String plus : String « String « Perl






String plus

     

#!C:\Perl\Bin\

$num1=25;
print "\n\n\$num1 = $num1\n\n";

$num2=10;
print "\$num2 = $num2\n\n";

$string1="20";
print "\$string1 = $string1\n\n";

$string2="Maximum Speed ";
print "\$string2 = $string2\n\n";

$result1 = $num1 + $num2;        # $result1 contains 35
print "\$result1 = $result1 \n\n";

$result2 = $result1 + $string1;        # $result2 contains 55
print "\$result2 = $result2 \n\n";

$result3 = $string2 . $result2;        # $result3 contains  "Maximum Speed 55"
print "\$result3 = $result3 \n\n";

   
    
    
    
    
  








Related examples in the same category

1.String Operations
2.String Operators: the right and wrong ways to perform an equivalence check on a string:
3.String variable
4.Strings are normally delimited by a matched pair of either double or single quotes.
5.ASCII Character Codes
6.A string is a sequence of bytes (characters) enclosed in quotes.
7.Calculation on string
8.Use print to output string
9.Append two string value
10.Perl 5 String Functions
11.Using ~ operator to check if a scalar is a string type variable
12.String Literals
13.String operators
14.String value reference