|Pathologically Eclectic Rubbish Lister|
Re: Re: Re: Re: "Correct" program style questionsby BrowserUk (Pope)
|on Oct 23, 2002 at 22:33 UTC||Need Help??|
Hmmm. My post, as stated, was simply asking why Ovid chose to use a temporary variable where it wasn't necessary. I'm beginning to hate the sight of that phrase 'cargo-cultish'. Especially when it is wrongly used to mean 'not the way I would do it'.
Using your version, if the 'name' param is completely omitted, then param('name') as you state will return undef. Which means that the attempt to apply the m// to results in
Which is exactly why the ||'' is there in the first place.
Your correct that this only delays the need to use defined to test for this, but I think that that delay is beneficial. Vis. Instead of,
You get the simpler, cleaner
This allows all the parameter validation to be done at the top of the script without needing temporary variables or to test at least twice for definedness, nicely grouped and with a consistant style, and allows us to bottle out early if we haven't got everything we need.
Not the only way to do it, maybe not the best way to do it, but it is a valid way and not without its merits. And its far from what I understand the definition of "cargo-cultish" to mean.
Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!