Customary Generic Meaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
- qu{} Literal yes, Unicode
`` qx{} Command yes (unless '' is delimiter)
qw{} Word list no
// m{} Pattern match yes (unless '' is delimiter)
See L<perlre> for additional information on valid syntax for STRING, and
for a detailed look at the semantics of regular expressions.
-=item qw/STRING/
-
-Evaluates to a list of the words extracted out of STRING, using embedded
-whitespace as the word delimiters. It can be understood as being roughly
-equivalent to:
-
- split(' ', q/STRING/);
-
-the difference being that it generates a real list at compile time. So
-this expression:
-
- qw(foo bar baz)
-
-is semantically equivalent to the list:
-
- 'foo', 'bar', 'baz'
-
-Some frequently seen examples:
-
- use POSIX qw( setlocale localeconv )
- @EXPORT = qw( foo bar baz );
-
-A common mistake is to try to separate the words with comma or to
-put comments into a multi-line C<qw>-string. For this reason, the
-C<use warnings> pragma and the B<-w> switch (that is, the C<$^W> variable)
-produces warnings if the STRING contains the "," or the "#" character.
-
-=item qu/STRING/
-
-Like L<qq> but generates Unicode for characters whose code points are
-greater than 128, or 0x80. Such characters can be generated using
-the \xHH (for characters 0x80...0xff, or 128..255) and \x{HHH...}
-notations (for characters 0x100..., or greater than 256).
-
-(In qq/STRING/, or "", both the \xHH and the \x{HHH...} generate
-bytes for the 0x80..0xff range (these bytes are host-dependent),
-and the \x{HHH...} can be used to generate Unicode.)
-
=item qx/STRING/
=item `STRING`
See L<"I/O Operators"> for more discussion.
+=item qw/STRING/
+
+Evaluates to a list of the words extracted out of STRING, using embedded
+whitespace as the word delimiters. It can be understood as being roughly
+equivalent to:
+
+ split(' ', q/STRING/);
+
+the difference being that it generates a real list at compile time. So
+this expression:
+
+ qw(foo bar baz)
+
+is semantically equivalent to the list:
+
+ 'foo', 'bar', 'baz'
+
+Some frequently seen examples:
+
+ use POSIX qw( setlocale localeconv )
+ @EXPORT = qw( foo bar baz );
+
+A common mistake is to try to separate the words with comma or to
+put comments into a multi-line C<qw>-string. For this reason, the
+C<use warnings> pragma and the B<-w> switch (that is, the C<$^W> variable)
+produces warnings if the STRING contains the "," or the "#" character.
+
=item s/PATTERN/REPLACEMENT/egimosx
Searches a string for a pattern, and if found, replaces that pattern
A string enclosed by backticks (grave accents) first undergoes
double-quote interpolation. It is then interpreted as an external
command, and the output of that command is the value of the
-pseudo-literal, j
-string consisting of all output is returned. In list context, a
-list of values is returned, one per line of output. (You can set
-C<$/> to use a different line terminator.) The command is executed
-each time the pseudo-literal is evaluated. The status value of the
-command is returned in C<$?> (see L<perlvar> for the interpretation
-of C<$?>). Unlike in B<csh>, no translation is done on the return
-data--newlines remain newlines. Unlike in any of the shells, single
-quotes do not hide variable names in the command from interpretation.
-To pass a literal dollar-sign through to the shell you need to hide
-it with a backslash. The generalized form of backticks is C<qx//>.
-(Because backticks always undergo shell expansion as well, see
-L<perlsec> for security concerns.)
+backtick string, like in a shell. In scalar context, a single string
+consisting of all output is returned. In list context, a list of
+values is returned, one per line of output. (You can set C<$/> to use
+a different line terminator.) The command is executed each time the
+pseudo-literal is evaluated. The status value of the command is
+returned in C<$?> (see L<perlvar> for the interpretation of C<$?>).
+Unlike in B<csh>, no translation is done on the return data--newlines
+remain newlines. Unlike in any of the shells, single quotes do not
+hide variable names in the command from interpretation. To pass a
+literal dollar-sign through to the shell you need to hide it with a
+backslash. The generalized form of backticks is C<qx//>. (Because
+backticks always undergo shell expansion as well, see L<perlsec> for
+security concerns.)
In scalar context, evaluating a filehandle in angle brackets yields
the next line from that file (the newline, if any, included), or
the value is automatically assigned to the global variable $_,
destroying whatever was there previously. (This may seem like an
odd thing to you, but you'll use the construct in almost every Perl
-script you write.) The $_ variables is not implicitly localized.
+script you write.) The $_ variable is not implicitly localized.
You'll have to put a C<local $_;> before the loop if you want that
to happen.
open(FOO, "echo *.c | tr -s ' \t\r\f' '\\012\\012\\012\\012'|");
while (<FOO>) {
- chop;
+ chomp;
chmod 0644, $_;
}