There's more than one way to do things PerlMonks

### Operators: arithmetic and otherwise

by root (Scribe)
 on Nov 17, 1999 at 01:12 UTC Need Help??

```\$a=2;
\$a=3;
...
print \$a.\$b   #string operator prints 2 plus the three or 23
print \$a*\$b   #arithmetic operator prints 6
print \$a x \$b #string operators prints \$a \$b times or 2 three times. i
+e 222
```
```\$a=3;
\$b="x";
...
\$a-=2;     #\$a=\$a-2; \$a is now equal to 3;
\$b x=3;    #\$b=\$b x \$3 \$b is now equal to "xxx";
\$b .="33"; #b=\$b."33"  \$b is now equal to "xxx33";
```
```\$a=1;
print \$a++; #prints a as one then adds 1 to it
print \$a;   #now \$a is 2
print ++\$a; #adds one to \$a and then prints its value which is now 3;
print \$a--; #prints 3 then subtracts one from \$a;
```

Create A New User
Node Status?
node history
Node Type: perltutorial [id://990]
help
Chatterbox?
 [marioroy]: Is List::Util::XS a core Perl module? [stevieb]: corelist List::Util::XS says "List::Util::XS was first released with perl v5.10.1" [stevieb]: so yes, since v5.10.1 :) [MidLifeXis]: According to [metaperl:// corelist], Perl 5.10.1 Lady_Aleena blurbles. One of her favorite modiles is now in "maintenance mode" in favor of a new fangled module. [MidLifeXis]: D'oh. Slow out of the gate. [marioroy]: Thanks stevieb, MidLifeXis.

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2017-05-24 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favorite model of computation is ...

Results (185 votes). Check out past polls.