programming-examples/perl/String/Chomp Last character removed only if a newline.pl

12 lines
234 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!usr/bin/perl
use warnings;
use strict;
print "Input something and we'll print it: ";
my $string = <STDIN>;
chomp( $string ); # Last character removed only if a newline
print "\nThis is safer. Still '$string.'\n";