in reply to Re: "Correct" program style questions
in thread "Correct" program style questions
my ( $color ) = (param('color') || '') =~ /^([[:alpha:]]+)$/;
That's an interesting line. My only immediate problem with it is that we come closer to obfuscating the code. People will likely understand the intent, but not necessarily see the subtleties. For instance, $color will be undef and not the empty string, if param('color') doesn't return anything. However, if the regular expression was stripped from the end of that, then $color would indeed default to the emptry string. Of course, I can't say that mine is much clearer in that regard.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: "Correct" program style questions
by sauoq (Abbot) on Oct 23, 2002 at 20:38 UTC | |
by BrowserUk (Patriarch) on Oct 23, 2002 at 22:33 UTC | |
by sauoq (Abbot) on Oct 24, 2002 at 01:09 UTC | |
by BrowserUk (Patriarch) on Oct 24, 2002 at 01:21 UTC | |
by sauoq (Abbot) on Oct 24, 2002 at 01:53 UTC | |
| |
by Ovid (Cardinal) on Oct 24, 2002 at 14:27 UTC | |
Re: Re: Re: "Correct" program style questions
by Anonymous Monk on Oct 23, 2002 at 19:08 UTC |
In Section
Seekers of Perl Wisdom