Полезная информация

Webmaster in a Nutshell

Previous Chapter 15
Perl Quick Reference
Next
 

15.2 Literals

Numeric

1231_234123.45E-100xff (hex)0377 (octal)

String

'abc'

Literal string, no variable interpolation or escape characters, except \' and \\. Also: q/abc/. Almost any pair of delimiters can be used instead of /.../.

"abc"

Variables are interpolated and escape sequences are processed. Also: qq/abc/.

Escape sequences: \t (Tab), \n (Newline), \r (Return),\f (Formfeed), \b (Backspace),\a (Alarm), \e (Escape), \033 (octal), \x1b (hex), \c[ (control).

\l and \u lowercase/uppercase the following character. \L and \U lowercase/uppercase until a \E is encountered. \Q quotes regular expression characters until a \E is encountered.

`command`

Evaluates to the output of the command. Also: qx/command/.

Array

(1, 2, 3)

( ) is an empty array.

(1..4) is the same as (1,2,3,4), likewise ('a'..'z').

qw/foo bar.../ is the same as ('foo','bar',...).

Array reference

[1,2,3]

Hash (associative array)

(key1, val1, key2, val2,...)

Also (key1 => val1, key2 => val2,...)

Hash reference

{key1, val1, key2, val2,...}

Code reference

sub { statements }

Filehandles

STDIN, STDOUT, STDERR, ARGV, DATA.

User-specified: handle, $var.

Globs

<pattern> evaluates to all filenames according to the pattern. Use <${var}> or glob $var to glob from a variable.

Here-Is

<<identifier

Shell-style "here document."

Special tokens

__FILE__: filename; __LINE__: line number;

__END__: end of program; remaining lines can be read using the filehandle DATA.


Previous Home Next
Command-Line Options Book Index Variables

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell