in reply to scalar values assignment

Please read perlintro. It shows you the syntax of the if statement.

Also note that you don't have to compare boolean values to true and false - you can just use them in an if statement. (And you are using an assignment anyway, not a comparison. Again read perlintro)

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: scalar values assignment
by sierpinski (Chaplain) on Apr 09, 2010 at 13:02 UTC
    That's true in most languages, if you're comparing whether or not a value is true or false, you don't have to explicitly add ' = true'. If you're unfamiliar with this concept, and how conditionals work, I'd strong recommend looking into general programming concepts. Not necessarily Perl, although if you're programming in Perl it would be a good place to start.

    Learning these basic concepts will help you pick up any programming language in the future. The concepts don't change, but the syntax does, and that's just a matter of googling and forums.
Re^2: scalar values assignment
by gogoglou (Beadle) on Apr 09, 2010 at 13:00 UTC

    I've read perlintro, and i've tried something like

    if ($scalar1! && $scalar2!){ then.... }

    still this didn't work. I also don't understand what you mean that I don't have to compare booleans to true or false. I am sorry if my questions seem a bit stupid and thank you for your time to reply to me.

      perlintro doesn't mention a then belonging to an if, because Perl is not Visual Basic.

      Just write

      if (defined(param('foo'))) { print "yes, we have a foo\n"; } else { print "out of luck, pal\n"; }
      I also don't understand what you mean that I don't have to compare booleans to true or false.

      The question is $thing the same as true? is nearly the same as is $thing true?. When you write if ($thing) { ... } then perl already asks is $thing true? - no need to make it more complicated by explcitly comparing it to true (which doesn't exist in Perl 5 anyway).

      The actual error message should be telling you where to look.

      Were you trying to form a NAND operator? !&& isn't legit.
      Also, the not operator (!) needs something to negate at the end of your conditional.