Variable Manipulation

Variable manipulation is grouped into a couple different groups. First there are the increment and decrement symbols (++ and --), the dot (.), substitution, and then split and join. Finally, there is the chomp command. These topics will be discussed in this order.

++, --

These two symbols increment and decrement the value of a variable by one. The following example shows incrementing the variable $penny by one and then decrementing it by one:

$penny++;
$penny--;

You will find this much quicker and easier than the following:

$penny += 1;
or
$penny = $penny -1;

The dot (.) is used to concatenate strings. Given the following two strings:

$string1 = "University of Kentucky Wildcats"; $string2 = "are the best basketball players ...

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.