in reply to Re: (tye)Re: How do you chomp your chomps?
in thread How do you chomp your chomps?
Well, heck. If we're gonna go that route, may as well golfuscate it:
sub my_chomp { substr shift, 0, (length) - 1 if $_[0] =~ /\n$/}; # :-)
Cheers,
Ovid
Update: Can anyone tell that I am *seriously* bored at work?
That ugly hack will work for both arrays and scalars (I think). I noticed that it appears to be returning an empty element at the end of the array, though. :(sub my_chomp { wantarray ? (map{ /\n$/ ? substr $_, 0, (length)-1 : $_ + } @_) : chomp(my $x = shift),$x };
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (Ovid -Golf) Re(3): How do you chomp your chomps?
by chromatic (Archbishop) on Jan 09, 2001 at 10:15 UTC | |
Re: Chomping Away (was Ovid Golf Chomps)
by mr.nick (Chaplain) on Jan 09, 2001 at 08:19 UTC |
In Section
Seekers of Perl Wisdom