Difference between revisions of "Perl"

From wiki
Jump to navigation Jump to search
Line 7: Line 7:
 
print Dumper($variable);
 
print Dumper($variable);
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
;$var += <value>
 +
:Add <value> to $var (works for -, *, / too)
 +
 +
;$string .= $addstring
 +
:Concatenate $string and $addstring
 +
 +
;$string = s/<regexp>/<newvalue>/[g]
 +
:Substitute <regexp> with <newvalue> in $string. The g modifier makes the all occurrences of <regexp> are substituted.

Revision as of 17:12, 14 February 2018

I'm leaving Perl, traded it for Python. Some shortcuts I'd like to remember

Print out the contents of $variable in a structured format.

use Data::Dumper;
print Dumper($variable);
$var += <value>
Add <value> to $var (works for -, *, / too)
$string .= $addstring
Concatenate $string and $addstring
$string = s/<regexp>/<newvalue>/[g]
Substitute <regexp> with <newvalue> in $string. The g modifier makes the all occurrences of <regexp> are substituted.