Difference between revisions of "Perl reference"
Jump to navigation
Jump to search
(→Escape Sequences: file test operators) |
|||
| Line 40: | Line 40: | ||
|- | |- | ||
| '''\x'''''nn'' || prints the ASCII character numbered ''nn'' in hexadecimal | | '''\x'''''nn'' || prints the ASCII character numbered ''nn'' in hexadecimal | ||
| + | |} | ||
| + | ==File Test Operators== | ||
| + | All operators are used like this: | ||
| + | -''x'' <u>$filename</u> | ||
| + | {| | ||
| + | |- | ||
| + | | '''-r''' || Is the file readable? | ||
| + | |- | ||
| + | | '''-w''' || Is the file writable? | ||
| + | |- | ||
| + | | '''-x''' || Is the file executable? | ||
| + | |- | ||
| + | | '''-e''' || Does the file exist? | ||
| + | |- | ||
| + | | '''-z''' || Is the file empty? (i.e. zero bytes) | ||
| + | |- | ||
| + | | '''-s''' || File length in bytes | ||
| + | |- | ||
| + | | '''-f''' || Is the file an ordinary file? | ||
| + | |- | ||
| + | | '''-d''' || Is the file a directory? | ||
| + | |- | ||
| + | | '''-l''' || Is the file a [[symbolic link]]? (UNIX/[[Linux]] only) | ||
| + | |- | ||
| + | | '''-p''' || Is file a [[named pipe]]? | ||
| + | |- | ||
| + | | '''-S''' || Is the file a [[socket (programming)|socket]]? | ||
| + | |- | ||
| + | | '''-T''' || Is the file a text file? | ||
| + | |- | ||
| + | | '''-B''' || Is the file a binary file? (!-T) | ||
| + | |- | ||
| + | | '''-M''' || Number of days since file was last modified | ||
| + | |- | ||
| + | | '''-A''' || Number of days since file was last accessed | ||
|} | |} | ||
Revision as of 22:29, 11 March 2006
Reference for various things in Perl. See also Perl built-in functions.
Escape Sequences
| \a | bell (ctrl-G, 007 decimal) |
| \b | backspace (ctrl-H, 008 decimal) |
| \cn | ctrl-n |
| \e | ESC (027 decimal, 033 octal) |
| \f | FF |
| \l | converts next letter to lowercase |
| \n | newline - system-dependent (CRLF on DOS/Win) |
| \r | CR (013 decimal) |
| \t | TAB (ctrl-I, 009 decimal) |
| \u | converts next letter to uppercase |
| \L | converts all characters to lowercase, from here to next \E |
| \U | converts all characters to uppercase, from here to next \E |
| \E | ends case conversion started by \L or \U |
| \' | prints a literal single-quote |
| \" | prints a literal double-quote |
| \$ | prints a literal dollar sign |
| \\ | prints a literal backslash (not doubled) |
| \0nnn | prints the ASCII character numbered nnn in octal |
| \xnn | prints the ASCII character numbered nn in hexadecimal |
File Test Operators
All operators are used like this:
-x $filename
| -r | Is the file readable? |
| -w | Is the file writable? |
| -x | Is the file executable? |
| -e | Does the file exist? |
| -z | Is the file empty? (i.e. zero bytes) |
| -s | File length in bytes |
| -f | Is the file an ordinary file? |
| -d | Is the file a directory? |
| -l | Is the file a symbolic link? (UNIX/Linux only) |
| -p | Is file a named pipe? |
| -S | Is the file a socket? |
| -T | Is the file a text file? |
| -B | Is the file a binary file? (!-T) |
| -M | Number of days since file was last modified |
| -A | Number of days since file was last accessed |