[assign] $variable = expression
[assign] $variable := command
[assign]
$variable [-= | += | *= | /= | %= | x= | .= | ||= | &&= ] expression
[assign]
$variable [-:= | +:= | *:= | /:= | %:= | x:= | .:= | ||:= | &&:= ] command
Evaluate the expression (= assignment) or command (:= assignment) on the right side of the assignment and store the result in a given variable. Optionally a Perl operator (- subtraction, + addition, * multiplication, / division, % modulo, x repeat string n-times, . concatenation, || logical OR, && logical AND) can precede the assignment, in which case the variable is assigned the result of applying given operator on its previous value and the value of the right side of the assignment.
Example 20. Assign XPath (node-set, string), or Perl results
xsh>$a=chapter/title;
xsh>$b="hallo world";
xsh>$c={ `uname` };
xsh>ls $a;
Example 21. Arithmetic expressions (XPath)
xsh>$a=5*100
# assign 500 to $a xsh>$a += 20
# add 20 to $a xsh>$a = (($a+5) div 10)
Example 22. Arithmetic expressions (Perl)
xsh>$a={ 5*100 }
xsh>$a = { join ';', split //,"hallo" }
# assigns "h;a;l;l;o" to $a
Example 23. Command result assignment
xsh>$doc := open "file.xml"
# open a document xsh>$copies := xcopy //foo into //bar
# copy elements and store the copies xsh>$wrappers := wrap "wrapper" $copies
# wrap each node from $copies to a new element "wrapper" and store the wrapping elements