in reply to What is the difference between a Statement and an Expression?
expression is just a way to calculate a value, using operators, build-in or your own functions.
statement is more ezoteric: it may be assigment, variable declaration (my,...), subroutine call, control structures (if, while, foreach, block = {}, pragma (use...), etc.
And now, IMO what confuses you: sometimes statement might have a value like expression has, and statement can be used also as expression sometimes. Simple example:
Here $line = <> is used as statement (reading a line from STDIN) and also as expression (returning value assigned to $line. String is TRUE if something (not undef) was read in, and undef is returned when End_Of_File was reached. It might be confusing for beginners, but it is extremely convenient.while ($line = <>) { print $line; }
Your experience will grow, and your fun using perl will follow. Welcome in monastery, and come again. There is lot of information for you around.
I gave you ++ for noticing the difference.
pmas
To make errors is human. But to make million errors per second, you need a computer.
|
---|