Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Feb 032009

Remove newline character from the end of a string in Perl


chomp() is useful when reading data from a file or from a user - it remove remove any newline character from the end of a string.


while (my $text = ) {
    print "You entered '$text'\n"; # newline from input is removed

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>