Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
Perl Monk, Perl Meditation
 
PerlMonks  

Re: What is the difference between a Statement and an Expression?

by azatoth (Curate)
on Aug 02, 2001 at 10:32 UTC ( #101595=note: print w/ replies, xml ) Need Help??


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

Seems confusing, doesn't it?

IMO, a statement is usually something like

if ($this == 1) { do_that($thing) };

Meaning part of your code that evaluates an expression, or EXPR. In this example, the EXPR is $this == 1, and the if statement evaluates it to return a certain value and perform a function based on the outcome.

It seems to me you are just beginning your journey in the world of Perl, and would do well to invest in a book - perhaps Learning Perl.

Update:

In the simplest possible terms :

Expression

# this is an expression $foo = 1; # so is this $bar = ($foo . $baz);

Statement

# statements are like : #if .. else #while .. do #for .. # etc etc

Azatoth a.k.a Captain Whiplash

Make Your Die Messages Full of Wisdom!
Get YOUR PerlMonks Stagename here!
Want to speak like a Londoner?


Comment on Re: What is the difference between a Statement and an Expression?
Select or Download Code
Re: Re: What is the difference between a Statement and an Expression?
by tomazos (Deacon) on Aug 02, 2001 at 12:32 UTC
    There is no technical difference between a statement and an expression. They are "human" terms.

    For example, one might say that...

    $x -= 1

    ..is a statement. "Decrease the value of x by one."

    Compare with:

    while ($x -= 1) { ... }

    ...where the same statement is being used as an expression.

    You should mentally parse the words statement and expression as just "piece of code".

    The EXPR context is another story however, and a has a very specific meaning to the Perl parser. That is an aside however. When people say expression they rarely mean precisely an EXPR context.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://101595]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-04-18 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls