Subject: | Proposed enhancement: handle $_ |
Robert,
Thanks for writing this module! I played around with the prototypes some and found a setup that can also handle chomping $_, e.g., in `map { chomped } "a\n", "b";`. Full report with testcases is at https://github.com/robertkrimen/Text-Chomped/issues/1 ; I am opening here as well in case this reaches you sooner. The proposed code is:
sub chomped(;+) {
my @retvals;
@_ = @{$_[0]} if ref $_[0] eq 'ARRAY';
unshift @_, $_ unless @_;
foreach my $val (@_) {
my $s = $val;
chomp $s;
push @retvals, $s;
}
return $#retvals ? @retvals : $retvals[0];
}
I am working on this in a fork at https://github.com/cxw42/Text-Chomped/tree/issue1 . Is this enhancement of interest to you? Thanks!
Chris White