Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
so that I get a default if the var isn't defined.$some_var = $some_possibly_undefined_var || 10
But then, genius that I am, I used a more complex version of it like this in an HTML::Template param() assignment.
which doesn't work.$template->param( some_var => $hash{some_possibly_undefined_key} || 10 )
What I've told perl to do is to assign the non-existent variable, or do "10", is that right?
But I don't get a "contant in void context" warning the way I would if I just put:
in the middle of my script.10;
Is there any way I could have caught that?
Nobody says perl looks like line-noise any more
kids today don't know what line-noise IS ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: What protects me from doing this stupid thing..?
by kyle (Abbot) on Aug 12, 2007 at 00:13 UTC | |
Re: What protects me from doing this stupid thing..?
by FunkyMonk (Chancellor) on Aug 12, 2007 at 00:16 UTC | |
by Anonymous Monk on Aug 12, 2007 at 05:49 UTC | |
by bobf (Monsignor) on Aug 12, 2007 at 19:58 UTC | |
Re: What protects me from doing this stupid thing..?
by wind (Priest) on Aug 12, 2007 at 00:18 UTC | |
by Cody Pendant (Prior) on Aug 12, 2007 at 02:19 UTC | |
by syphilis (Archbishop) on Aug 12, 2007 at 03:04 UTC | |
by dogz007 (Scribe) on Aug 12, 2007 at 18:12 UTC | |
Re: What protects me from doing this stupid thing..?
by gam3 (Curate) on Aug 12, 2007 at 11:58 UTC |