126
L</"X">, L<perlvar/$">, L<perlop/Quote and Quote‐like Operators>
127
L</q(X)>, L</'X'> L</"X">, L<perlvar/$">,
128
and L<perlop/Quote and Quote‐like Operators>
134
This belongs to L<perlop/Terms and List Operators (Leftward)> and
135
L<perlop/Quote and Quote‐like Operators>.
139
This is the single quote operator (aka the non-interpolating string operator).
140
It creates a string literal out of X.
142
To place a C<'> inside the string, you must escape it with C<\>:
144
my $quote = 'He said \'I like quotes.\'';
146
Unlike double quoted strings, that is the only escape sequence.
148
For a full discussion of how strings work, see
149
L<perlop/Quote and Quote-like Operators>.
154
my $string = 'Hello, $name!\n'; #$string is now "Hello \$name!\n";
158
L</">, L</qq(X)>, L</q(X)>, L<perlvar/$">,
159
and L<perlop/Quote and Quote‐like Operators>
165
This belongs to L<perlop/Terms and List Operators (Leftward)> and
166
L<perlop/Quote and Quote‐like Operators>.
170
This is the generalized single quote operator (aka the generalized
171
non-interpolating string operator). It creates a string literal out of X.
173
The delimiters C<()> are chosen by the user and may consist of either
174
bracketing characters (C<< q<> >>, C<q()>, C<q{}>, and C<q[]>) or matching
175
characters (C<q##>, C<qaa>, etc.). It is generally used to allow the user
176
to avoid having to escape characters:
178
my $quote = q/He said 'I like quotes.'/;
180
If the delimiter is not a bracketing pair, or if the brackets are
181
unbalanced, you will need to escape the delimiter with C<\> if you wish to
182
have that character in the string:
184
my $quote = q{I have too many \} characters};
186
But it is often better to just choose a delimiter that does not conflict
189
my $better = q/I have too many } characters/;
191
Unlike double quoted strings, the escaping of the delimiter is the only
194
For a full discussion of how strings work, see
195
L<perlop/Quote and Quote-like Operators>.
200
my $string = q/Hello, $name!\n/; #$string is now "Hello \$name!\n";
204
L</"X">, L</'X'>, L</q(X)>, L<perlvar/$">,
205
and L<perlop/Quote and Quote‐like Operators>
211
This is the quote word operator. It creates a list of strings. The
212
individual strings are whitespace separated. It does not interpolate.
214
The delimiters C<()> are chosen by the user and may consist of either
215
bracketing characters (C<< qw<> >>, C<qw()>, C<qw{}>, and C<qw[]>) or
216
matching characters (C<qw##>, C<qwaa>, etc.). It is generally used to allow
217
the user to avoid having to escape characters:
219
my @list = qw/'a' 'b' 'c'/; #@list is now ("'a'", "'b'", "'c'")
221
If the delimiter is not a bracketing pair, or if the brackets are
222
unbalanced, you will need to escape the delimiter with C<\> if you wish to
223
have that character in the string:
225
my @broken = qw{I have too many } characters}; #broken
226
my @works = qw{I have too many \} characters}; #works
227
my @balanced = qw{this works {} because it is balanced} #works
229
But it is often better to just choose a delimiter that does not conflict
232
my $better = qw/I have too many } characters/;
234
Unlike double quoted strings, the escaping of the delimiter is the only
239
my @a = qw/ a b c /; #@a is now ("a", "b", "c", "d")
240
my @b = qw/ $foo $bar /; #@b is now ('$foo', '$bar')
244
L</'X'>, L</q(X)>, and L<perlop/Quote and Quote‐like Operators>