in reply to Syntax errors with {s

I often have trouble with nested if/else statements as well and sometimes they can be a bugger to fix. But it looks like you're only missing two }'s.

You're not closing your first and your second IF, that's where the problems occur. So all I did was added a closed bracket after the first and second ELSE. Please see the script below.

if (param()) { my $name = param("name"); my $email = param("email"); my $phone = param("phone"); my $url = param("url"); my $requests = param("requests"); if ($name ne "") { if ($email ne "") { if ($requests ne "") { print "very good!"; } else { print "please leave a message"; } } else { print "please enter your email"; } } else { print "please enter your name"; } }


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re^2: Syntax errors with {s
by ikegami (Patriarch) on Oct 10, 2004 at 18:47 UTC
    sometimes they can be a bugger to fix.

    I can see such problems being hard to fix when (and only when) the brackets are not lined up like in the solution you gave...

      On guard!

      Each coder has their own way they prefer to see and write code. I much prefer doubling up the closures then break into a new line.

      Many might argue with this being harder to read, but I've been pretty constant with it since the very beginning.



      "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

      sulfericacid