programming-examples/perl/String/Chop Removing the last character, regardless of what it is.pl

17 lines
375 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>;
print "\nOur input ( $string ) contains a newline. Remove it:\n";
chop( $string );
print "\nThis is more like it: '$string' without the newline.\n";
my $character = chop( $string );
print "\nWe removed $character; now it is '$string.'\n";