in reply to modifying perl functions without having to write own functions...
They will expect $chomped to contain the number of elements chomped as documented, not the first element of the array post-chomping. So unless you want to maintain a list of all the built-ins you've over-ridden at the top of your code and have any future programmers working on the code referring back to it constantly, you're better off just writing your own function. The two examples you give are trivially written asmy $chomped = chomp (@array)
which are just as easy to use as the built-ins, but give different names to different behavior and are consequently much more obvious to the reader.sub chomp_and_return { chomp @_; return @_; } sub lc_array { map { lc } @_; }
If after reading and considering this post you still want to over-ride the built-ins with different behavior, see the "Overriding Built-in Functions" heading of perlsub.
|
|---|