Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> [...]
>
>>Yes! That's also another _very_ good reason to type comparaisons with the
>>constant
>>on the left side. I always try to write it in that order, and by now, my brain
>>is fully adjusted to it.
>>
>>if ("Inherit" eq $var) {
>>elsif ("Enable" eq $var) {
>>elsif ("Disable" eq $var) {
>>
>>Also puts the things being looked for first, making the statement somewhat
>>clearer
>>to me.
>
> I suppose when all you use is a hammer, everything looks like a nail :)
>
> What if sometimes it's $var and at other times $bar? e.g. what reads better:
>
> if ("FooBar" eq $var) {
> elsif ("444" eq $bar) {
> elsif ("foobartar" eq $bar) {
>
> or:
>
> if ($var eq "FooBar") {
> elsif ($bar eq "444") {
> elsif ($bar eq "foobartar") {
>
> the second version is much more parsable if you ask me.
Yup, I agree with you in that example. In cascasing if/elsif/elsif,
I guess the trick is to try and keep the most significant element of
the comparaison to the left.
> I admit my variables nicely align, which makes it easier to read :)
if ("FooBar" eq $var) {
elsif ("444" eq $bar) {
elsif ("foobartar" eq $bar) {
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
signature.asc
Description: OpenPGP digital signature
