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.
In reply to Re: chop vs chomp
by pg
in thread chop vs chomp
by xoombot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |