in reply to chop() and chomp()
Note that the whole string in $/ needs to be present to be considered an "end-of-line" (it doesn't pick out portions of $/), and that it won't remove embedded $/'s.$/='abc'; $_='lafbabc'; chomp; print; ##prints 'lafb', removes 'abc' as expected $_='lafbabcq'; chomp; print; ## prints 'lafbabcq', does not remove embedded 'abc' $_='lafbab'; chomp; print; ## prints 'lafbab', does not remove partial $/ -- 'ab' $_='lafbc'; chomp; print; ## prints 'lafbc', does not remove partial $/ - 'bc' $_='lafabcabc'; chomp; print; ##prints 'lafabc', only removes ONE $/
I'm going to reserve upvotes/downvotes -- I think you can improve the tutorial considerably and make it worthy of an upvote.chomp $a, $b; ## this means chomp $a, but leave $b alone! chomp ($a, $b); ## this means chomp both
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: chop() and chomp()
by TGI (Parson) on May 25, 2007 at 22:18 UTC |