Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: is $i=+3 valid?

by hdb (Monsignor)
on Jul 05, 2013 at 07:27 UTC ( [id://1042630]=note: print w/replies, xml ) Need Help??


in reply to is $i=+3 valid?

You got your answer already to change =+ to +=. However, why do not just experiment a little bit. It is really easy to write:

use strict; use warnings; my $i=0; $i=+3; print "$i\n"; # no errors, so far, prints 3, so we should be fine...? $i=+3; # better try again print "$i\n"; # still prints 3, so something must be wrong! $i=$i+3; # check whether Perl works correctly... print "$i\n"; # prints 6, what a relief

Experiments are fun! (Unless you are a theoretical physicist...)

Replies are listed 'Best First'.
Re^2: is $i=+3 valid?
by Happy-the-monk (Canon) on Jul 05, 2013 at 08:32 UTC

    However, why do not just experiment a little bit.

    Or you make it a rhyme. Need to re-name $i to $e to make it a rhyme:

    ++$e for 1 .. 3;

    Cheers, Sören

    (hooked on the Perl Programming language)

      How to increment by 3, is wondering he (or she). Plus equal or equal plus, what a fuzz! Just try it out and see or stay in the dark will he.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-24 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found