Is there anything in core Perl to auto-chomp lines from "<>" operator?
input, perl
Solution
Beyond the asquerous source filters that you already mentioned, I’m afraid I don’t know what counts as “a hack” for your purposes here. Do you consider any of these obviousish solutions to be “hacks”?
- overriding `*CORE::readline` in the current package
- overriding `*CORE::GLOBAL::readline` in all packages
- handle ties to a class with a custom `READLINE` method
- operator overloading of the `<>` operator
Have you tried those yet?
Of those, I would think the first, or possibly the second, to be the most likely to do what you want with the least amount of fuss.
Note that all four of those solutions require nothing but pure Perl and nothing else. They do not even require any core modules, let alone any CPAN modules.
Problem
One of the minor annoyances I have when doing Perl coding is the necessity to remember to chomp a line that you read from input. Yeah, after years of coding it's nearly automatic to remember to do so, but STILL annoying. Is there any pragma, module or anything else in Perl (strongly preferred Core modules) that automatically chomps every line read using a `<>` operator?