in reply to chop vs chomp

Try this demo:

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]"; }

It prints (observe it):

[01234][0123456789][012345][0123456789]

And read perlfunc.