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$/}; # :-)


Update: Can anyone tell that I am *seriously* bored at work?

sub my_chomp { wantarray ? (map{ /\n$/ ? substr $_, 0, (length)-1 : $_ + } @_) : chomp(my $x = shift),$x };
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. :(

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.