in reply to Re: No braces
in thread No braces

I didn't mean that "just in perl" it's counter-intuitive, I meant, the way perl forces you to do it is counter-intuitive. Of course what is intuitive differs depending on the person, I just find it much more natural to put the condition first. I would never say, "I use my umbrella if it rains." I would say, "If it rains, I'll use my umbrella." Of course as the reply stated below, I could wrap the whole thing in parens and use && but that (IMO of course) is still not as intuitive as saying if(COND) do_something(); I've been working with perl now for years and I still pause and scratch my head when I see that in code. I fear I'll never get used to it.

Either way, I didn't mean to say that it was only counter-intuitive in perl.

Replies are listed 'Best First'.
Re: No braces
by Abigail-II (Bishop) on Feb 11, 2004 at 22:16 UTC
    I meant, the way perl forces you to do it is counter-intuitive.
    But Perl doesn't require you to do it this way. Perl allows to put either the cause, or the effect to go first.

    Abigail

      Sort of. You can only say if(COND) { do_something; } - you can't leave off the braces and still use that construct. You'd have to do something more funky using &&, etc.