programming-examples/perl/String/Difference between chomp and chop.pl
2019-11-15 12:59:38 +01:00

14 lines
423 B
Perl

#!C:/perl/bin
$/ = "\n";
$stringvalue = "This is a string \n";
chomp $stringvalue;
print "The string that had a newline character becomes: $stringvalue";
print " and this is a following string\n\n";
$stringvalue = "This is a string"; # note no \n in the string
chomp $stringvalue;
print "The string that had NO newline character becomes: $stringvalue";
print " and this is a following string\n\n";