I've noticed that perlfunc has some bad advice and examples on the use
of chop, showing and advocating its use as a way to strip newlines
from input. This is what chomp() is for, of course, and isn't
cross-platform (although perlport doesn't bring it up, odd).
Anyhow, I cut out all the naughty bits from perlfunc, but I can't
think of good chop examples to replace:
while (<>) {
chop; # avoid \n on last field
@array = split(/:/);
#...
}
and
chop($cwd = `pwd`);
chop($answer = <STDIN>);
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Any sufficiently encapsulated hack is no longer a hack.
- Re: Need better chop examples. Michael G Schwern
- Re: Need better chop examples. Benjamin Holzman
- Re: Need better chop examples. Michael G Schwern
- Re: Need better chop examples. Benjamin Holzman
- Re: Need better chop examples. abigail
- Re: Need better chop examples. Karsten Sperling
- Re: Need better chop examples. Sam Tregar
- Re: Need better chop examples. Simon Cozens
- Re: Need better chop examples. nick
- Re: Need better chop examples. abigail
- Re: Need better chop examples. Benjamin Franz
