Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I can understand why you are confused. Here is my attempt to add light to darkness.. :)

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:

while ($line = <>) { print $line; }
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.
You'll find many idioms like this, Larry Wall (inventor of perl) made perl so flexible, there is even abbreviation for that: TIMTOWTDI - There Is More Than One Way To Do It. Perl tries to help you. Just always  use strict and use -w switch, everything else will come along.

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.


In reply to Re: What is the difference between a Statement and an Expression? by pmas
in thread What is the difference between a Statement and an Expression? by supernewbie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-03-28 10:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found