This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
notes:perl_cheat_sheet [2026/09/14 01:01] 49.37.116.225 old revision restored (2026/08/03 07:47) |
notes:perl_cheat_sheet [2026/09/14 06:02] (current) 216.73.217.14 old revision restored (2026/09/12 20:46) |
||
|---|---|---|---|
| Line 18: | Line 18: | ||
| * All numbers are stored in the same format e.g.-6.5e24, | * All numbers are stored in the same format e.g.-6.5e24, | ||
| * Underscores for readability are ignored e.g. 0x1377_0B77 | * Underscores for readability are ignored e.g. 0x1377_0B77 | ||
| - | * Arithmetic operators are * / + - % (modulus) | + | * Arithmetic operators are * / + - % (modulus) ** (exponentiation) |
| * Comparison operators are < <= == >= > != | * Comparison operators are < <= == >= > != | ||
| Line 73: | Line 73: | ||
| $count += 2; | $count += 2; | ||
| }</ | }</ | ||
| - | * foreach loop <code perl> | + | * foreach loop <code perl> |
| # modifications to $rock modify the list element | # modifications to $rock modify the list element | ||
| # $_ is used if loop variable is omitted | # $_ is used if loop variable is omitted | ||
| Line 83: | Line 83: | ||
| * '' | * '' | ||
| * Assigning < | * Assigning < | ||
| - | |||
| - | ===== User Subroutines ===== | ||
| - | |||
| - | * Subroutines are in their own namespace and are typically called using ''& | ||
| - | * Subroutines can be defined anywhere e.g. <code perl> sub mysub { | ||
| - | my($m, $n) = @_ | ||
| - | $m + $n; | ||
| - | } </ | ||
| - | * The value of the last expression evaluated is returned. But '' | ||
| - | * Arguments are in the list @_ . If ''& | ||
| - | * Lexical scoped variables can be used in any block by prefixing with '' | ||
| - | * Ampersand is optional if subroutine has previously been declared or if parenthesis are used. Ampersand is not optional if built-in subroutine is being overridden. | ||