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]"; } #### [01234][0123456789][012345][0123456789]