use strict; use warnings; { my $str = "0123456789"; for (1 .. 5) { chop $str; } print "[$str]"; } { my $str = "0123456789"; for (1 .. 5) { chomp $str; } print "[$str]"; } { my $str = "0123456789\n"; for (1 .. 5) { chop $str; } print "[$str]"; } { my $str = "0123456789\n"; for (1 .. 5) { chomp $str; } print "[$str]"; }