David Caughell has asked for the wisdom of the Perl Monks concerning the following question:
I know that Perl has a miriad of shortcuts, and this is one of the reasons that I really like the language.
However, something that I think would be pretty cool, is if it was possible to write a conditional statement within a loop in a one-liner.
I haven't checked out the source code of perl, so I don't know how complex it would be to add something like this to the language (or how much slower a script would run).
#how it currently works for (@arr) { print "$_\n" if /pattern/; } #what I'm suggesting print "$_\n" if /pattern/ for @arr;
Are there technical difficulties implementing something of this kind?
Are there reasons that doing something like this would be bad programming?
Thanks,
Dave.
$scratchpad_public = 0 unless $scratchpad;
Back to
Seekers of Perl Wisdom