http://www.perlmonks.org?node_id=101914


in reply to What is the difference between a Statement and an Expression?

First of all, I ++ you for comming up with topic that generated as much conversation as this one has. If I were asked to define on a test the difference between the two, but I failed to study (which was usually the case in high school) I would probably write something like this:
A statement (in perl) is anything that is ended with a ";" while an expression is the part of a statement that actually does something like a mathematical computation, or the assigning of a value etc. The statement doesn't necessarly contain an expression. In reality, as long as you and those you are communicating with know what you are talking about, it doesn't matter what you call it.

Stuffy
That's my story, and I'm sticking to it, unless I'm wrong in which case I will probably change it ;~)
may be reproduced under the SDL
  • Comment on Re: What is the difference between a Statement and an Expression?

Replies are listed 'Best First'.
Re^2: What is the difference between a Statement and an Expression?
by JavaFan (Canon) on Mar 02, 2012 at 01:25 UTC
    A statement (in perl) is anything that is ended with a ";" while an expression is the part of a statement that actually does something like a mathematical computation, or the assigning of a value etc.
    So, in
    for (my $i = 0; $i < 10; $i++) { print "\$i = "; print $i }
    there are three statements, my $i = 0;, $i < 10; and print "\$i = ";, but print $i isn't, and neither is the entire for construct?

    Curious.