Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

chomp

  • chomp
#!/usr/bin/perl
use strict;
use warnings;

print "Enter your name, please: ";
my $name = <STDIN>;
chomp $name;
print "Hello $name - how are you ?\n";

chomp will remove the new line "\n" character from the end of the string if there was one.