www.webdeveloper.com
Results 1 to 2 of 2

Thread: perl help for a newbie please

  1. #1
    Join Date
    May 2003
    Posts
    3

    perl help for a newbie please

    if $x = 10 then the statement, if ($x++ == 10) { print("7\n")} is true, but could someone please explain to me in very plain terms, why it is true. I would have thought that it was false because 10 incremented by 1 = 11, thank you.

  2. #2
    Join Date
    Nov 2002
    Location
    Dartmoor [Holiday]
    Posts
    2,382
    $x++ returns x (i.e. 10) then increments it by one, like doing this:

    if ($x == 10)
    then
    $x = $x + 1

    If you use ++$x, it first increments the variable then returns it.

    Adam

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles