wolis has asked for the wisdom of the Perl Monks concerning the following question:
Just a tiny question on the use of:
Is there a simpler way to just say "if val is blank then set it to a default value" without having to refer to the $val three times in the one line?$val = ($val ne '') ? $val : $default_val;
I know I can write a function (do we call them functions even tho the are 'Sub's?) - oops thats a second question! - but I was wondering what secrets Perl has that might do this.
Thanks,
___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: default values
by Limbic~Region (Chancellor) on Sep 16, 2003 at 01:59 UTC | |
by wolis (Scribe) on Sep 16, 2003 at 07:14 UTC | |
by Limbic~Region (Chancellor) on Sep 16, 2003 at 16:18 UTC | |
by wolis (Scribe) on Sep 18, 2003 at 03:30 UTC | |
Re: default values
by stajich (Chaplain) on Sep 16, 2003 at 02:05 UTC | |
by BUU (Prior) on Sep 16, 2003 at 05:19 UTC | |
by tachyon (Chancellor) on Sep 16, 2003 at 06:56 UTC | |
by liz (Monsignor) on Sep 16, 2003 at 07:44 UTC | |
by Anonymous Monk on Sep 16, 2003 at 15:20 UTC | |
Re: default values
by flounder99 (Friar) on Sep 16, 2003 at 11:52 UTC | |
Re: default values
by mpd (Monk) on Sep 16, 2003 at 02:03 UTC |