Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
or, using the fancy new switch feature,while(<>){ if(/.../){...} elsif(/.../){...} elsif(/.../){...} }
Altho the given-when thing is cool, it would be cooler if the given() could be left out. It seems like the kind of thing that should be possible, because it's kind of, well, a given. Apparently it can be left out in a for() loop, but not in while(). And you can't use a for() loop in this case. Or can you?while(<>){ given($_){ when(...){...} when(...){...} when(...){...} }}
And, by the way, is there an even shorter way to do print "\n"; ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Succinct switch statement
by jakobi (Pilgrim) on Oct 23, 2009 at 20:30 UTC | |
by Bloodnok (Vicar) on Oct 23, 2009 at 23:32 UTC | |
|
Re: Succinct switch statement
by bichonfrise74 (Vicar) on Oct 23, 2009 at 21:39 UTC | |
|
Re: Succinct switch statement
by keszler (Priest) on Oct 23, 2009 at 22:21 UTC | |
by chromatic (Archbishop) on Oct 23, 2009 at 23:30 UTC | |
|
Re: Succinct switch statement
by JadeNB (Chaplain) on Oct 24, 2009 at 01:56 UTC | |
|
Re: Succinct switch statement
by moritz (Cardinal) on Oct 23, 2009 at 20:38 UTC | |
by ikegami (Patriarch) on Oct 23, 2009 at 21:04 UTC | |
by moritz (Cardinal) on Oct 24, 2009 at 13:58 UTC | |
by Anonymous Monk on Oct 23, 2009 at 21:18 UTC | |
by toolic (Bishop) on Oct 23, 2009 at 21:34 UTC | |
by ikegami (Patriarch) on Oct 23, 2009 at 22:07 UTC | |
by markkawika (Monk) on Oct 23, 2009 at 21:49 UTC | |
by toolic (Bishop) on Oct 23, 2009 at 23:21 UTC |