~ubuntu-branches/ubuntu/precise/padre/precise

« back to all changes in this revision

Viewing changes to share/doc/perlopref/perlopref.pod

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-05-08 09:17:22 UTC
  • mfrom: (1.2.1 upstream) (10.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100508091722-y6008jtk0ap6znyn
Tags: 0.60.ds1-3
rules: run tests with HOME=$fake_home to avoud failing when $HOME points
to a non-existent location. Closes: #579289

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
 
69
69
=head3 See also
70
70
 
71
 
L</qq(X)>, L<perlvar/$">, L<perlop/Quote and Quote‐like Operators>
 
71
L</qq(X)>, L</'X'>, L</q(X)>, L<perlvar/$">, 
 
72
and L<perlop/Quote and Quote‐like Operators>
72
73
 
73
74
=head2 qq(X)
74
75
 
123
124
 
124
125
=head3 See also
125
126
 
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>
 
129
 
 
130
=head2 'X'
 
131
 
 
132
=head3 Class
 
133
 
 
134
This belongs to L<perlop/Terms and List Operators (Leftward)> and 
 
135
L<perlop/Quote and Quote‐like Operators>.
 
136
 
 
137
=head3 Description
 
138
 
 
139
This is the single quote operator (aka the non-interpolating string operator).
 
140
It creates a string literal out of X.
 
141
 
 
142
To place a C<'> inside the string, you must escape it with C<\>:
 
143
 
 
144
    my $quote = 'He said \'I like quotes.\'';
 
145
 
 
146
Unlike double quoted strings, that is the only escape sequence.
 
147
 
 
148
For a full discussion of how strings work, see 
 
149
L<perlop/Quote and Quote-like Operators>. 
 
150
 
 
151
=head3 Example
 
152
 
 
153
    my $name   = 'World';
 
154
    my $string = 'Hello, $name!\n'; #$string is now "Hello \$name!\n";
 
155
 
 
156
=head3 See also
 
157
 
 
158
L</">, L</qq(X)>, L</q(X)>, L<perlvar/$">, 
 
159
and L<perlop/Quote and Quote‐like Operators>
 
160
 
 
161
=head2 q(X)
 
162
 
 
163
=head3 Class
 
164
 
 
165
This belongs to L<perlop/Terms and List Operators (Leftward)> and 
 
166
L<perlop/Quote and Quote‐like Operators>.
 
167
 
 
168
=head3 Description
 
169
 
 
170
This is the generalized single quote operator (aka the generalized
 
171
non-interpolating string operator).  It creates a string literal out of X.
 
172
 
 
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:
 
177
 
 
178
     my $quote = q/He said 'I like quotes.'/;
 
179
 
 
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:
 
183
 
 
184
    my $quote = q{I have too many \} characters};
 
185
 
 
186
But it is often better to just choose a delimiter that does not conflict
 
187
with the string:
 
188
 
 
189
    my $better = q/I have too many } characters/;
 
190
 
 
191
Unlike double quoted strings, the escaping of the delimiter is the only
 
192
escape.
 
193
 
 
194
For a full discussion of how strings work, see 
 
195
L<perlop/Quote and Quote-like Operators>. 
 
196
 
 
197
=head3 Example
 
198
 
 
199
    my $name   = "World";
 
200
    my $string = q/Hello, $name!\n/; #$string is now "Hello \$name!\n";
 
201
 
 
202
=head3 See also
 
203
 
 
204
L</"X">, L</'X'>, L</q(X)>, L<perlvar/$">, 
 
205
and L<perlop/Quote and Quote‐like Operators>
 
206
 
 
207
=head2 qw(X)
 
208
 
 
209
=head3 Description
 
210
 
 
211
This is the quote word operator.  It creates a list of strings.  The
 
212
individual strings are whitespace separated.  It does not interpolate.
 
213
 
 
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:
 
218
 
 
219
     my @list = qw/'a' 'b' 'c'/; #@list is now ("'a'", "'b'", "'c'")
 
220
 
 
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:
 
224
 
 
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
 
228
 
 
229
But it is often better to just choose a delimiter that does not conflict
 
230
with the string:
 
231
 
 
232
    my $better = qw/I have too many } characters/;
 
233
 
 
234
Unlike double quoted strings, the escaping of the delimiter is the only
 
235
escape.
 
236
 
 
237
=head3 Example
 
238
 
 
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')
 
241
 
 
242
=head3 See Also
 
243
 
 
244
L</'X'>, L</q(X)>, and L<perlop/Quote and Quote‐like Operators>
127
245
 
128
246
=head2 X[Y]
129
247