Don't ask to ask, just ask | |
PerlMonks |
Re: Shorten this one-liner!by Marshall (Canon) |
on Aug 25, 2018 at 23:28 UTC ( [id://1221107]=note: print w/replies, xml ) | Need Help?? |
I did not find your code particularly easy to understand. An alternate coding could be like the following... tr is a lot faster than using the regex engine. I think shortening the code to a one-liner is a meaningless exercise. Update: I don't see the reason to make a "one liner" other than to do it for the fun of doing it. This makes no difference in execution speed. White space and comments consume no MIPS and the difference in Perl compile speed is insignificant. This $words[$count] is very anti-Perl philosophy... subscripts are rare. Learn more Perl before trying to write a one-liner.
Another Update: I asked a Python friend and here is one result: I like my Perl code much better!
In Section
Seekers of Perl Wisdom
|
|