Read input lines and concatenate them. : Concatenate « String « Perl






Read input lines and concatenate them.

    

#!/usr/local/bin/perl 
$resultstring = ""; 
print("Enter your input - type an empty line to quit\n"); 
$input = <STDIN>; 
chop ($input); 
while ($input ne "") { 
    $resultstring .= $input; 
    $input = <STDIN>; 
    chop ($input); 
} 
print ("Here is the final string:\n"); 
print ("$resultstring\n"); 

   
    
    
    
  








Related examples in the same category

1.Concatenate string
2.Concatenate strings
3.Concatenate the separate strings
4.Concatenate two string value in print statement
5.Concatenate two strings
6.String concatenate operator
7.Combine string concatenation operator and string multiplication operator