programming-examples/perl/String/The chomp function is a safer version of chop.pl
2019-11-15 12:59:38 +01:00

16 lines
441 B
Perl

chomp VARIABLE
chomp LIST
chomp
chomp removes any line ending that corresponds to the current value of $/.
$/ is the special Perl variable holding the input record separator.
$/ is defaulting to a newline.
chomp function returns the total number of characters removed.
chomp is usually used to remove the newline from the end of an input record.
If VARIABLE is omitted, it chomps $_.
while (<>) {
chomp;
print;
}