argv has asked for the wisdom of the Perl Monks concerning the following question:
My example is below, where I coerce chomp to return the EXPR it acted upon:
open FILE, "list-of-emails-one-per-line.txt"; @emails{(array) chomp <FILE>} = (); # %emails is now a hash where each + key is an email address close FILE;
So, I'd like to add this "coercing" behavior without having to write a new special-case chomp function. A similar thing would be to extend "lc" (et al.) to act on an array as well as a string.
Is this possible, or am I stuck writing my own functions? UPDATE: Please don't tell me how to solve the specific task illustrated in the example (such as using "chomp (@_ = <FILE>), @_" to simply yield the desired list. That isn't answering the question on whether "extensions" to existing functions are possible.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: modifying perl functions without having to write own functions...
by ikegami (Patriarch) on Dec 23, 2006 at 18:19 UTC | |
|
Re: modifying perl functions without having to write own functions...
by dirving (Friar) on Dec 23, 2006 at 19:21 UTC |