programming-examples/perl/String/Difference between chomp and chop.pl

14 lines
423 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!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";