| \ | % | # | Assignment |
| Command-Line | Environment | Examples | Format |
| Functions | Io | Looping | Math |
| Operators | Pattern | Precedence | Random |
| Stacks | Subroutines | Switch | Text |
| Unix | Variables | Windows |
| \\ | backslash | \" | double-quote | \a | bell | ||
| \b | backspace | \cC | control-'C' | \e | escape | ||
| \E | terminate \L or \U | \f | formfeed | \l | lowercase next char | ||
| \L | lowercase 'til \E | \n | newline | \r | carriage return | ||
| \t | tab | \u | uppercase next char | \U | uppercase 'til \E | ||
| \v | vertical tab | \177 | octal 'delete' | \ooo | octal char | ||
| \xhh | hex char |
.
format someformatname =
fieldline
value1, value2, value3
fieldline
value1, value2
.
.
format ADDRESSLABEL =
====================================
| @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
$name
| @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
$address
| @<<<<<<<<<<<<<<<<<<<<<, @< @<<<< |
$city, $state, $zip
====================================
.
open(ADDRESSLABEL,">file-to-write-to");
($name,$address,$city,$state,$zip) = split(/:/);
#read in the fields
write ADDRESSLABEL; #this will write appropriately
to include special signs (-/$/etc...) use the sub:
sub cool
{
local($n,$width) = @_;
#back off for negative stuff;2
$width -= 2;
@n = sprintf("%.2f",$n);
if ($n < 0)
{
#negative numbers get brackets
sprintf("[%$width.2f]", -$n);
}
else
{
#positive #'s get spaces
sprintf(" %$width.2f]", $n);
}
}
$pwd = (getpwuid($<))[1];
$salt = substr($pwd, 0, 2);
system "stty -echo";
print "Password: ";
chop($word = );
print "\n";
system "stty echo";
if(crypt($word, $salt) ne $pwd)
{ die "Sorry...\n"; }
else { print "ok\n"; }
use Fcntl;
fcntl($filehandle, F_GETLK, $packed_return_buffer);
my $BSD_STYLE = 1;
sub getsingle()
{
if ($BSD_STYLE)
{ system "stty cbreak /dev/tty 2>&1"; }
else
{ system "stty", '-icanon', 'eol', "\001"; }
my $tmp = getc(STDIN);
if ($BSD_STYLE)
{ system "stty -cbreak /dev/tty 2>&1"; }
else
{ system "stty", 'icanon', 'eol', '^@'; # ascii null }
print "\n";
return $tmp;
}
$filename =~ s{
^ ~ # find a leading tilde
( # save this in $1
[^/] # a non-slash character
* # repeated 0 or more times (0 means me)
)
}{
$1
? (getpwnam($1))[7]
: ( $ENV{HOME} || $ENV{LOGDIR} )
}ex;
| -r | readable | -w | writable | |
| -x | executable | -o | owned by user | |
| -e | exists | -z | exists & 0 size | |
| -s | size in bytes | -f | plain file | |
| -d | directory | -l | symlink | |
| -k | sticky-bit set | -T | text file | |
| -B | binary file | -M | modification age (days) | |
| -A | access age in days | -C | inode-modification age |
| subject | strings | numbers | ||
|---|---|---|---|---|
| concatenation | . | |||
| equality | eq | == | ||
| not equal | ne | != | ||
| less than | < | < | ||
| greater than | > | > | ||
| less than/equal | <= | <= | ||
| greater than/equal | >= | >= |
| s | replace | ! | not |
| g | replace all (cannot be used with tr) |
| i | case insensitive |
| c | complement the searchlist |
| d | delete found but unreplaced characters |
| s | squash duplicate replaced characters |
| o | evaluate the regular expression one time only |
| ^ | start of string | $ | end of string | \b | word boundry | ||
| \B | not word boundry | \d | digits | \D | not-digits | ||
| \f | form feed | \t | tab | \n | newline | ||
| \r | carriage return | \w | alphanumeric | \W | not alphanumeric | ||
| \s | whitespace | \S | not whitespace | a|b | match only one of a or b |
| * | 0 or more | + | 1 or more | |
| ? | 0 or 1 | {n} | 'n' instances | |
| {n,} | at least 'n' instances | {n,m} | at least n, at most m |
| associativity | operator |
|---|---|
| none | the 'list' operators |
| left | , |
| right | += ('assignment' operators) |
| right | ?: (trinary if/then/else) |
| none | .. (range operator, list constructor) |
| left | || (or) |
| left | && (and) |
| left | | ^ (bitwise or & exclusive or) |
| left | & (bitwise and) |
| none | == != <=> eq ne cmp ('equal' operators) |
| none | < <= > >= lt le gt ge ('not-equal' operators) |
| none | named unary operators |
| none | file test operators |
| left | << >> (bit shift) |
| left | + - .(string concatenation) |
| left | * / % x(string repetition) |
| left | =~(match) !~(doesn't match) |
| right | ** (exponentiation) |
| right | ! ~(bitwise not) - |
| none | ++ -- |
use Text::Wrap;
print wrap("\t", ' ', @paragraphs);