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/15 08:46] 216.73.216.243 old revision restored (2026/09/11 13:05) |
notes:perl_cheat_sheet [2026/09/16 15:17] (current) 216.73.216.94 old revision restored (2026/09/14 11:37) |
||
|---|---|---|---|
| Line 13: | Line 13: | ||
| * Comments start with # (no block comments) | * Comments start with # (no block comments) | ||
| * Parenthesis are optional unless part of syntax. | * Parenthesis are optional unless part of syntax. | ||
| - | * '' | ||
| ===== Numbers ===== | ===== Numbers ===== | ||
| Line 83: | Line 82: | ||
| * Read a line of input - '' | * Read a line of input - '' | ||
| * '' | * '' | ||
| - | * Assigning < | + | * Assigning < |
| - | * Loop over input ($_ can only be used in this specific case) <code perl> | + | |
| - | print "I saw $_"; | + | |
| - | }</ | + | |
| - | * '' | + | |
| - | * ''<>'' | + | |
| - | chomp; | + | |
| - | print "It was $_ that I saw!\n"; | + | |
| - | }</ | + | |
| - | * '' | + | |
| - | print sort <>; | + | |
| - | * C-like printf function %g for number auto-format, | + | |
| ===== User Subroutines ===== | ===== User Subroutines ===== | ||
| Line 102: | Line 91: | ||
| $m + $n; | $m + $n; | ||
| } </ | } </ | ||
| - | * The value of the last expression evaluated is returned. But '' | + | * The value of the last expression evaluated is returned. |
| - | * A list can be returned if the subroutine is called in a list context ('' | + | |
| * Arguments are in the list @_ . If ''& | * Arguments are in the list @_ . If ''& | ||
| * Lexical scoped variables can be used in any block by prefixing with '' | * Lexical scoped variables can be used in any block by prefixing with '' | ||
| - | * In Perl 5.10 and up '' | ||
| - | * 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. | ||