On Sun, Jan 28, 2001 at 01:06:31AM +0100, [EMAIL PROTECTED] wrote:
> I don't think there are any good examples. If there were any good
> examples, it would mean chop would be a useful function to have.
> But after the arrival of chomp, they only reason to keep chop is backwards
> compatability.
chomp gets rid of what my system calls newlines. chop gets rid of newlines
in data that comes from other systems too.
The following fragment is from some production code; we're turning a bunch of
relative (percentage) and absolute sizes into all absolutes.
my @percents = grep /\d+%$/, @sizes;
croak "At least one argument to ->sizes() needs to be pixels"
unless @percents < @sizes;
my @constants = grep { !/\d+%/ } @sizes;
# Right.
my $c = 0; $c += $_ for @constants;
chop @percents;
my $p = 0; $p += $_ for @percents;
The chop is there to get rid of "argument not numeric" warnings.
Sure, it's rare, but it's not unused. Seems odd that there isn't a symmetric
function to take stuff off the other end, though, especially given we have the
offset hack.
--
`After all, we're not all freaky perverts' - Thorfinn