Should Perl have a `chomped` function?
rchomp, but Aristotle’s suggestion of
chomped is perfect!
brian d foy posed an interesting interview question: “What five things do you hate most about language X?” positing that an experienced user of X should know 5 things (s)he hates about it.
In my list is the return value of
chomp. Yes I understand why it works as it does
print "chomped" if chomp $input;
but I find that use case happens far less often than the usual
chomp( my $input = <> );
Wouldn’t it be great to have a
chomp function that returns the chomped value or values? In the spirit of the new
s///r flag I originally wanted to call it
rchomp, Aristotle’s comment of
chomped is my new favorite. You would use it like:
my $input = chomped <>;
Since we all love CPAN of course I could make a CPAN module for this, but no one would add a dependency on it just for one convenience function. I don’t expect large adoption of my
Tie::Select for this reason, even thought I think it has reasons to be safer than the core’s
SelectSaver in some rare circumstances.
So anyway, is
chomped something that the community would want? Could it possibly be in
CORE:: so that people might actually use it? I even see that a similar concept made an rfc for Perl6. Just daydreaming I guess, but oooh I do hate it.