perl5ever has asked for the wisdom of the Perl Monks concerning the following question:
I know I can effectively accomplish the same thing with a do statement and introducing a dummy lexical:my $suffix = given ($type) { when ("csv") { "txt" } when ("xml") { "xml" } };
Is there another way to use given...when... in a "functional" way which avoids introducing a do statement and a dummy lexical?my $suffix = do { my $result; given ($type) when ("csv") { $result = "txt" } when ("xml") { $result = "xml" } ... } $result };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: functional "given...when..."?
by BrowserUk (Patriarch) on Mar 15, 2010 at 19:43 UTC | |
by perl5ever (Pilgrim) on Mar 15, 2010 at 19:57 UTC | |
|
Re: functional "given...when..."?
by almut (Canon) on Mar 15, 2010 at 20:02 UTC | |
|
Re: functional "given...when..."?
by JavaFan (Canon) on Mar 16, 2010 at 11:32 UTC | |
|
Re: functional "given...when..."?
by JavaFan (Canon) on Mar 16, 2010 at 11:30 UTC | |
by BrowserUk (Patriarch) on Mar 16, 2010 at 11:42 UTC |