Debian Codegraph @

templates/man1/perlsyn.1.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:34+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 # #-#-#-#-# fedora-44: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
20 #
21 # #-#-#-#-# fedora-rawhide: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
22 #
23 # #-#-#-#-# mageia-cauldron: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
24 #
25 # #-#-#-#-# opensuse-leap-16-1: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
26 #
27 # #-#-#-#-# opensuse-tumbleweed: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
28 #
29 #. #-#-#-#-# debian-trixie: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
30 #. ========================================================================
31 #. type: IX
32 #. #-#-#-#-# debian-unstable: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
33 #. ========================================================================
34 #. type: IX
35 #. #-#-#-#-# fedora-44: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
36 #. Required to disable full justification in groff 1.23.0.
37 #. ========================================================================
38 #. type: IX
39 #. #-#-#-#-# fedora-rawhide: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
40 #. Required to disable full justification in groff 1.23.0.
41 #. ========================================================================
42 #. type: IX
43 #. #-#-#-#-# mageia-cauldron: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
44 #. Required to disable full justification in groff 1.23.0.
45 #. ========================================================================
46 #. type: IX
47 #. #-#-#-#-# opensuse-leap-16-1: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
48 #. Required to disable full justification in groff 1.23.0.
49 #. ========================================================================
50 #. type: IX
51 #. #-#-#-#-# opensuse-tumbleweed: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
52 #. Required to disable full justification in groff 1.23.0.
53 #. ========================================================================
54 #. type: IX
55 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
56 #: opensuse-leap-16-1 opensuse-tumbleweed
57 #, no-wrap
58 msgid "Title"
59 msgstr ""
60
61 # #-#-#-#-# fedora-44: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
62 #
63 # #-#-#-#-# fedora-rawhide: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
64 #
65 # #-#-#-#-# mageia-cauldron: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
66 #
67 # #-#-#-#-# opensuse-leap-16-1: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
68 #
69 # #-#-#-#-# opensuse-tumbleweed: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
70 #
71 #. #-#-#-#-# debian-trixie: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
72 #. ========================================================================
73 #. type: IX
74 #. #-#-#-#-# debian-unstable: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
75 #. ========================================================================
76 #. type: IX
77 #. #-#-#-#-# fedora-44: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
78 #. Required to disable full justification in groff 1.23.0.
79 #. ========================================================================
80 #. type: IX
81 #. #-#-#-#-# fedora-rawhide: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
82 #. Required to disable full justification in groff 1.23.0.
83 #. ========================================================================
84 #. type: IX
85 #. #-#-#-#-# mageia-cauldron: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
86 #. Required to disable full justification in groff 1.23.0.
87 #. ========================================================================
88 #. type: IX
89 #. #-#-#-#-# opensuse-leap-16-1: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
90 #. Required to disable full justification in groff 1.23.0.
91 #. ========================================================================
92 #. type: IX
93 #. #-#-#-#-# opensuse-tumbleweed: perlsyn.1.pot (PACKAGE VERSION) #-#-#-#-#
94 #. Required to disable full justification in groff 1.23.0.
95 #. ========================================================================
96 #. type: IX
97 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
98 #: opensuse-leap-16-1 opensuse-tumbleweed
99 #, no-wrap
100 msgid "PERLSYN 1"
101 msgstr ""
102
103 #. type: TH
104 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
105 #: opensuse-leap-16-1 opensuse-tumbleweed
106 #, no-wrap
107 msgid "PERLSYN"
108 msgstr ""
109
110 #. type: TH
111 #: debian-trixie
112 #, no-wrap
113 msgid "2025-07-27"
114 msgstr ""
115
116 #. type: TH
117 #: debian-trixie debian-unstable
118 #, no-wrap
119 msgid "perl v5.40.1"
120 msgstr ""
121
122 #. type: TH
123 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
124 #: opensuse-leap-16-1 opensuse-tumbleweed
125 #, no-wrap
126 msgid "Perl Programmers Reference Guide"
127 msgstr ""
128
129 #. type: SH
130 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
131 #: opensuse-leap-16-1 opensuse-tumbleweed
132 #, no-wrap
133 msgid "NAME"
134 msgstr ""
135
136 #. type: Plain text
137 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
138 #: opensuse-leap-16-1 opensuse-tumbleweed
139 msgid "perlsyn - Perl syntax: declarations, statements, comments"
140 msgstr ""
141
142 #. type: IX
143 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
144 #: opensuse-leap-16-1 opensuse-tumbleweed
145 #, no-wrap
146 msgid "Xref"
147 msgstr ""
148
149 #. type: IX
150 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
151 #: opensuse-leap-16-1 opensuse-tumbleweed
152 #, no-wrap
153 msgid "syntax"
154 msgstr ""
155
156 #. type: IX
157 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
158 #: opensuse-leap-16-1 opensuse-tumbleweed
159 #, no-wrap
160 msgid "DESCRIPTION"
161 msgstr ""
162
163 #. type: IX
164 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
165 #: opensuse-leap-16-1 opensuse-tumbleweed
166 #, no-wrap
167 msgid "Header"
168 msgstr ""
169
170 #. type: Plain text
171 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
172 #: opensuse-leap-16-1 opensuse-tumbleweed
173 msgid ""
174 "A Perl program consists of a sequence of declarations and statements which "
175 "run from the top to the bottom. Loops, subroutines, and other control "
176 "structures allow you to jump around within the code."
177 msgstr ""
178
179 #. type: Plain text
180 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
181 #: opensuse-leap-16-1 opensuse-tumbleweed
182 msgid ""
183 "Perl is a B<free-form> language: you can format and indent it however you "
184 "like. Whitespace serves mostly to separate tokens, unlike languages like "
185 "Python where it is an important part of the syntax, or Fortran where it is "
186 "immaterial."
187 msgstr ""
188
189 #. type: Plain text
190 #: debian-trixie debian-unstable
191 msgid ""
192 "Many of Perl's syntactic elements are B<optional>. Rather than requiring "
193 "you to put parentheses around every function call and declare every "
194 "variable, you can often leave such explicit elements off and Perl will "
195 "figure out what you meant. This is known as B<Do What I Mean>, abbreviated "
196 "B<DWIM>. It allows programmers to be B<lazy> and to code in a style with "
197 "which they are comfortable."
198 msgstr ""
199
200 #. type: Plain text
201 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
202 #: opensuse-leap-16-1 opensuse-tumbleweed
203 msgid ""
204 "Perl B<borrows syntax> and concepts from many languages: awk, sed, C, Bourne "
205 "Shell, Smalltalk, Lisp and even English. Other languages have borrowed "
206 "syntax from Perl, particularly its regular expression extensions. So if you "
207 "have programmed in another language you will see familiar pieces in Perl. "
208 "They often work the same, but see perltrap for information about how they "
209 "differ."
210 msgstr ""
211
212 #. type: IX
213 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
214 #: opensuse-leap-16-1 opensuse-tumbleweed
215 #, no-wrap
216 msgid "Declarations"
217 msgstr ""
218
219 #. type: IX
220 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
221 #: opensuse-leap-16-1 opensuse-tumbleweed
222 #, no-wrap
223 msgid "declaration undef undefined uninitialized"
224 msgstr ""
225
226 #. type: IX
227 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
228 #: opensuse-leap-16-1 opensuse-tumbleweed
229 #, no-wrap
230 msgid "Subsection"
231 msgstr ""
232
233 #. type: Plain text
234 #: debian-trixie debian-unstable
235 msgid ""
236 "The only things you need to declare in Perl are report formats and "
237 "subroutines (and sometimes not even subroutines). A scalar variable holds "
238 "the undefined value (CW<\\*(C`undef\\*(C'>) until it has been assigned a "
239 "defined value, which is anything other than CW<\\*(C`undef\\*(C'>. When "
240 "used as a number, \\&CW<\\*(C`undef\\*(C'> is treated as CW<0>; when used as "
241 "a string, it is treated as the empty string, CW<\"\">; and when used as a "
242 "reference that isn't being assigned to, it is treated as an error. If you "
243 "enable warnings, you'll be notified of an uninitialized value whenever you "
244 "treat \\&CW<\\*(C`undef\\*(C'> as a string or a number. Well, usually. "
245 "Boolean contexts, such as:"
246 msgstr ""
247
248 #. type: Plain text
249 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
250 #: opensuse-leap-16-1 opensuse-tumbleweed
251 #, no-wrap
252 msgid "\\& if ($x) {}\n"
253 msgstr ""
254
255 #. type: Plain text
256 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
257 #: opensuse-leap-16-1 opensuse-tumbleweed
258 msgid ""
259 "are exempt from warnings (because they care about truth rather than "
260 "definedness). Operators such as CW<\\*(C`++\\*(C'>, CW<\\*(C`--\\*(C'>, "
261 "CW<\\*(C`+=\\*(C'>, \\&CW<\\*(C`-=\\*(C'>, and CW<\\*(C`.=\\*(C'>, that "
262 "operate on undefined variables such as:"
263 msgstr ""
264
265 #. type: Plain text
266 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
267 #: opensuse-leap-16-1 opensuse-tumbleweed
268 #, no-wrap
269 msgid ""
270 "\\& undef $x;\n"
271 "\\& $x++;\n"
272 msgstr ""
273
274 #. type: Plain text
275 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
276 #: opensuse-leap-16-1 opensuse-tumbleweed
277 msgid "are also always exempt from such warnings."
278 msgstr ""
279
280 #. type: Plain text
281 #: debian-trixie debian-unstable
282 msgid ""
283 "A declaration can be put anywhere a statement can, but has no effect on the "
284 "execution of the primary sequence of statements: declarations all take "
285 "effect at compile time. All declarations are typically put at the beginning "
286 "or the end of the script. However, if you're using lexically-scoped private "
287 "variables created with CW<my()>, \\&CW<state()>, or CW<our()>, you'll have "
288 "to make sure your format or subroutine definition is within the same block "
289 "scope as the my if you expect to be able to access those private variables."
290 msgstr ""
291
292 #. type: Plain text
293 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
294 #: opensuse-leap-16-1 opensuse-tumbleweed
295 msgid ""
296 "Declaring a subroutine allows a subroutine name to be used as if it were a "
297 "list operator from that point forward in the program. You can declare a "
298 "subroutine without defining it by saying CW<\\*(C`sub name\\*(C'>, thus:"
299 msgstr ""
300
301 #. type: IX
302 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
303 #: opensuse-leap-16-1 opensuse-tumbleweed
304 #, no-wrap
305 msgid "subroutine, declaration"
306 msgstr ""
307
308 #. type: Plain text
309 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
310 #: opensuse-leap-16-1 opensuse-tumbleweed
311 #, no-wrap
312 msgid ""
313 "\\& sub myname;\n"
314 "\\& $me = myname $0 or die \"can\\*(Aqt get myname\";\n"
315 msgstr ""
316
317 #. type: Plain text
318 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
319 #: opensuse-leap-16-1 opensuse-tumbleweed
320 msgid ""
321 "A bare declaration like that declares the function to be a list operator, "
322 "not a unary operator, so you have to be careful to use parentheses (or "
323 "\\&CW<\\*(C`or\\*(C'> instead of CW<\\*(C`||\\*(C'>.) The CW<\\*(C`||"
324 "\\*(C'> operator binds too tightly to use after list operators; it becomes "
325 "part of the last element. You can always use parentheses around the list "
326 "operators arguments to turn the list operator back into something that "
327 "behaves more like a function call. Alternatively, you can use the prototype "
328 "CW<\\*(C`($)\\*(C'> to turn the subroutine into a unary operator:"
329 msgstr ""
330
331 #. type: Plain text
332 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
333 #: opensuse-leap-16-1 opensuse-tumbleweed
334 #, no-wrap
335 msgid ""
336 "\\& sub myname ($);\n"
337 "\\& $me = myname $0 || die \"can\\*(Aqt get myname\";\n"
338 msgstr ""
339
340 #. type: Plain text
341 #: debian-trixie debian-unstable
342 msgid ""
343 "That now parses as you'd expect, but you still ought to get in the habit of "
344 "using parentheses in that situation. For more on prototypes, see perlsub."
345 msgstr ""
346
347 #. type: Plain text
348 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
349 #: opensuse-leap-16-1 opensuse-tumbleweed
350 msgid ""
351 "Subroutines declarations can also be loaded up with the "
352 "CW<\\*(C`require\\*(C'> statement or both loaded and imported into your "
353 "namespace with a CW<\\*(C`use\\*(C'> statement. See perlmod for details on "
354 "this."
355 msgstr ""
356
357 #. type: Plain text
358 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
359 #: opensuse-leap-16-1 opensuse-tumbleweed
360 msgid ""
361 "A statement sequence may contain declarations of lexically-scoped variables, "
362 "but apart from declaring a variable name, the declaration acts like an "
363 "ordinary statement, and is elaborated within the sequence of statements as "
364 "if it were an ordinary statement. That means it actually has both compile-"
365 "time and run-time effects."
366 msgstr ""
367
368 #. type: IX
369 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
370 #: opensuse-leap-16-1 opensuse-tumbleweed
371 #, no-wrap
372 msgid "Comments"
373 msgstr ""
374
375 #. type: IX
376 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
377 #: opensuse-leap-16-1 opensuse-tumbleweed
378 #, no-wrap
379 msgid "comment #"
380 msgstr ""
381
382 #. type: Plain text
383 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
384 #: opensuse-leap-16-1 opensuse-tumbleweed
385 msgid ""
386 "Text from a CW<\"#\"> character until the end of the line is a comment, and "
387 "is ignored. Exceptions include CW<\"#\"> inside a string or regular "
388 "expression."
389 msgstr ""
390
391 #. type: IX
392 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
393 #: opensuse-leap-16-1 opensuse-tumbleweed
394 #, no-wrap
395 msgid "Simple Statements"
396 msgstr ""
397
398 #. type: IX
399 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
400 #: opensuse-leap-16-1 opensuse-tumbleweed
401 #, no-wrap
402 msgid "statement semicolon expression ;"
403 msgstr ""
404
405 #. type: Plain text
406 #: debian-trixie debian-unstable
407 msgid ""
408 "The only kind of simple statement is an expression evaluated for its side-"
409 "effects. Every simple statement must be terminated with a semicolon, unless "
410 "it is the final statement in a block, in which case the semicolon is "
411 "optional. But put the semicolon in anyway if the block takes up more than "
412 "one line, because you may eventually add another line. Note that there are "
413 "operators like CW<\\*(C`eval {}\\*(C'>, CW<\\*(C`sub {}\\*(C'>, and "
414 "\\&CW<\\*(C`do {}\\*(C'> that I<look> like compound statements, but aren't--"
415 "they're just TERMs in an expression--and thus need an explicit termination "
416 "when used as the last item in a statement."
417 msgstr ""
418
419 #. type: IX
420 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
421 #: opensuse-leap-16-1 opensuse-tumbleweed
422 #, no-wrap
423 msgid "Statement Modifiers"
424 msgstr ""
425
426 #. type: IX
427 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
428 #: opensuse-leap-16-1 opensuse-tumbleweed
429 #, no-wrap
430 msgid "statement modifier modifier if unless while until when foreach for"
431 msgstr ""
432
433 #. type: Plain text
434 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
435 #: opensuse-leap-16-1 opensuse-tumbleweed
436 msgid ""
437 "Any simple statement may optionally be followed by a I<SINGLE> modifier, "
438 "just before the terminating semicolon (or block ending). The possible "
439 "modifiers are:"
440 msgstr ""
441
442 #. type: Plain text
443 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
444 #: opensuse-leap-16-1 opensuse-tumbleweed
445 #, no-wrap
446 msgid ""
447 "\\& if EXPR\n"
448 "\\& unless EXPR\n"
449 "\\& while EXPR\n"
450 "\\& until EXPR\n"
451 "\\& for LIST\n"
452 "\\& foreach LIST\n"
453 "\\& when EXPR\n"
454 msgstr ""
455
456 #. type: Plain text
457 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
458 #: opensuse-leap-16-1 opensuse-tumbleweed
459 msgid ""
460 "The CW<\\*(C`EXPR\\*(C'> following the modifier is referred to as the "
461 "\"condition\". Its truth or falsehood determines how the modifier will "
462 "behave."
463 msgstr ""
464
465 #. type: Plain text
466 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
467 #: opensuse-leap-16-1 opensuse-tumbleweed
468 msgid ""
469 "\\&CW<\\*(C`if\\*(C'> executes the statement once I<if> and only if the "
470 "condition is true. CW<\\*(C`unless\\*(C'> is the opposite, it executes the "
471 "statement I<unless> the condition is true (that is, if the condition is "
472 "false). See \"Scalar values\" in perldata for definitions of true and false."
473 msgstr ""
474
475 #. type: Plain text
476 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
477 #: opensuse-leap-16-1 opensuse-tumbleweed
478 #, no-wrap
479 msgid ""
480 "\\& print \"Basset hounds got long ears\" if length $ear E<gt>= 10;\n"
481 "\\& go_outside() and play() unless $is_raining;\n"
482 msgstr ""
483
484 #. type: Plain text
485 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
486 #: opensuse-leap-16-1 opensuse-tumbleweed
487 msgid ""
488 "The CW<for(each)> modifier is an iterator: it executes the statement once "
489 "for each item in the LIST (with CW<$_> aliased to each item in turn). There "
490 "is no syntax to specify a C-style for loop or a lexically scoped iteration "
491 "variable in this form."
492 msgstr ""
493
494 #. type: Plain text
495 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
496 #: opensuse-leap-16-1 opensuse-tumbleweed
497 #, no-wrap
498 msgid "\\& print \"Hello $_!\\en\" for qw(world Dolly nurse);\n"
499 msgstr ""
500
501 #. type: Plain text
502 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
503 #: opensuse-leap-16-1 opensuse-tumbleweed
504 msgid ""
505 "\\&CW<\\*(C`while\\*(C'> repeats the statement I<while> the condition is "
506 "true. Postfix CW<\\*(C`while\\*(C'> has the same magic treatment of some "
507 "kinds of condition that prefix CW<\\*(C`while\\*(C'> has. "
508 "\\&CW<\\*(C`until\\*(C'> does the opposite, it repeats the statement "
509 "I<until> the condition is true (or while the condition is false):"
510 msgstr ""
511
512 #. type: Plain text
513 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
514 #: opensuse-leap-16-1 opensuse-tumbleweed
515 #, no-wrap
516 msgid ""
517 "\\& # Both of these count from 0 to 10.\n"
518 "\\& print $i++ while $i E<lt>= 10;\n"
519 "\\& print $j++ until $j E<gt> 10;\n"
520 msgstr ""
521
522 #. type: Plain text
523 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
524 #: opensuse-leap-16-1 opensuse-tumbleweed
525 msgid ""
526 "The CW<\\*(C`while\\*(C'> and CW<\\*(C`until\\*(C'> modifiers have the usual "
527 "\"CW<\\*(C`while\\*(C'> loop\" semantics (conditional evaluated first), "
528 "except when applied to a \\&CW<\\*(C`do\\*(C'>-BLOCK (or to the Perl4 "
529 "CW<\\*(C`do\\*(C'>-SUBROUTINE statement), in which case the block executes "
530 "once before the conditional is evaluated."
531 msgstr ""
532
533 #. type: Plain text
534 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
535 #: opensuse-leap-16-1 opensuse-tumbleweed
536 msgid "This is so that you can write loops like:"
537 msgstr ""
538
539 #. type: Plain text
540 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
541 #: opensuse-leap-16-1 opensuse-tumbleweed
542 #, no-wrap
543 msgid ""
544 "\\& do {\n"
545 "\\& $line = E<lt>STDINE<gt>;\n"
546 "\\& ...\n"
547 "\\& } until !defined($line) || $line eq \".\\en\"\n"
548 msgstr ""
549
550 #. type: Plain text
551 #: debian-trixie debian-unstable
552 msgid ""
553 "See \"do\" in perlfunc. Note also that the loop control statements "
554 "described later will I<NOT> work in this construct, because modifiers don't "
555 "take loop labels. Sorry. You can always put another block inside of it "
556 "(for CW<\\*(C`next\\*(C'>/CW<\\*(C`redo\\*(C'>) or around it (for "
557 "CW<\\*(C`last\\*(C'>) to do that sort of thing."
558 msgstr ""
559
560 #. type: IX
561 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
562 #: opensuse-leap-16-1 opensuse-tumbleweed
563 #, no-wrap
564 msgid "next last redo"
565 msgstr ""
566
567 #. type: Plain text
568 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
569 #: opensuse-leap-16-1 opensuse-tumbleweed
570 msgid ""
571 "For CW<\\*(C`next\\*(C'> or CW<\\*(C`redo\\*(C'>, just double the braces:"
572 msgstr ""
573
574 #. type: Plain text
575 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
576 #: opensuse-leap-16-1 opensuse-tumbleweed
577 #, no-wrap
578 msgid ""
579 "\\& do {{\n"
580 "\\& next if $x == $y;\n"
581 "\\& # do something here\n"
582 "\\& }} until $x++ E<gt> $z;\n"
583 msgstr ""
584
585 #. type: Plain text
586 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
587 #: opensuse-leap-16-1 opensuse-tumbleweed
588 msgid ""
589 "For CW<\\*(C`last\\*(C'>, you have to be more elaborate and put braces "
590 "around it:"
591 msgstr ""
592
593 #. type: IX
594 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
595 #: opensuse-leap-16-1 opensuse-tumbleweed
596 #, no-wrap
597 msgid "last"
598 msgstr ""
599
600 #. type: Plain text
601 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
602 #: opensuse-leap-16-1 opensuse-tumbleweed
603 #, no-wrap
604 msgid ""
605 "\\& {\n"
606 "\\& do {\n"
607 "\\& last if $x == $y**2;\n"
608 "\\& # do something here\n"
609 "\\& } while $x++ E<lt>= $z;\n"
610 "\\& }\n"
611 msgstr ""
612
613 #. type: Plain text
614 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
615 #: opensuse-leap-16-1 opensuse-tumbleweed
616 msgid ""
617 "If you need both CW<\\*(C`next\\*(C'> and CW<\\*(C`last\\*(C'>, you have to "
618 "do both and also use a loop label:"
619 msgstr ""
620
621 #. type: Plain text
622 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
623 #: opensuse-leap-16-1 opensuse-tumbleweed
624 #, no-wrap
625 msgid ""
626 "\\& LOOP: {\n"
627 "\\& do {{\n"
628 "\\& next if $x == $y;\n"
629 "\\& last LOOP if $x == $y**2;\n"
630 "\\& # do something here\n"
631 "\\& }} until $x++ E<gt> $z;\n"
632 "\\& }\n"
633 msgstr ""
634
635 #. type: Plain text
636 #: debian-trixie debian-unstable
637 msgid ""
638 "\\&B<NOTE:> The behaviour of a CW<\\*(C`my\\*(C'>, CW<\\*(C`state\\*(C'>, or "
639 "\\&CW<\\*(C`our\\*(C'> modified with a statement modifier conditional or "
640 "loop construct (for example, CW<\\*(C`my $x if ...\\*(C'>) is "
641 "\\&B<undefined>. The value of the CW<\\*(C`my\\*(C'> variable may be "
642 "CW<\\*(C`undef\\*(C'>, any previously assigned value, or possibly anything "
643 "else. Don't rely on it. Future versions of perl might do something "
644 "different from the version of perl you try it out on. Here be dragons."
645 msgstr ""
646
647 #. type: IX
648 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
649 #: opensuse-leap-16-1 opensuse-tumbleweed
650 #, no-wrap
651 msgid "my"
652 msgstr ""
653
654 #. type: Plain text
655 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
656 #: opensuse-leap-16-1 opensuse-tumbleweed
657 msgid ""
658 "The CW<\\*(C`when\\*(C'> modifier is an experimental feature that first "
659 "appeared in Perl 5.14. To use it, you should include a CW<\\*(C`use "
660 "v5.14\\*(C'> declaration. (Technically, it requires only the "
661 "CW<\\*(C`switch\\*(C'> feature, but that aspect of it was not available "
662 "before 5.14.) Operative only from within a CW<\\*(C`foreach\\*(C'> loop or "
663 "a CW<\\*(C`given\\*(C'> block, it executes the statement only if the "
664 "smartmatch \\&CW<\\*(C`$_ ~~ >\\f(CIEXPRCW<\\*(C'> is true. If the "
665 "statement executes, it is followed by a CW<\\*(C`next\\*(C'> from inside a "
666 "CW<\\*(C`foreach\\*(C'> and CW<\\*(C`break\\*(C'> from inside a "
667 "CW<\\*(C`given\\*(C'>."
668 msgstr ""
669
670 #. type: Plain text
671 #: debian-trixie debian-unstable
672 msgid ""
673 "Under the current implementation, the CW<\\*(C`foreach\\*(C'> loop can be "
674 "anywhere within the CW<\\*(C`when\\*(C'> modifier's dynamic scope, but must "
675 "be within the CW<\\*(C`given\\*(C'> block's lexical scope. This restriction "
676 "may be relaxed in a future release. See \"Switch Statements\" below."
677 msgstr ""
678
679 #. type: IX
680 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
681 #: opensuse-leap-16-1 opensuse-tumbleweed
682 #, no-wrap
683 msgid "Compound Statements"
684 msgstr ""
685
686 #. type: IX
687 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
688 #: opensuse-leap-16-1 opensuse-tumbleweed
689 #, no-wrap
690 msgid "statement, compound block bracket, curly curly bracket brace { } if unless given while until foreach for continue"
691 msgstr ""
692
693 #. type: Plain text
694 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
695 #: opensuse-leap-16-1 opensuse-tumbleweed
696 msgid ""
697 "In Perl, a sequence of statements that defines a scope is called a block. "
698 "Sometimes a block is delimited by the file containing it (in the case of a "
699 "required file, or the program as a whole), and sometimes a block is "
700 "delimited by the extent of a string (in the case of an eval)."
701 msgstr ""
702
703 #. type: Plain text
704 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
705 #: opensuse-leap-16-1 opensuse-tumbleweed
706 msgid ""
707 "But generally, a block is delimited by curly brackets, also known as "
708 "braces. We will call this syntactic construct a BLOCK. Because enclosing "
709 "braces are also the syntax for hash reference constructor expressions (see "
710 "perlref), you may occasionally need to disambiguate by placing a "
711 "\\&CW<\\*(C`;\\*(C'> immediately after an opening brace so that Perl "
712 "realises the brace is the start of a block. You will more frequently need "
713 "to disambiguate the other way, by placing a CW<\\*(C`+\\*(C'> immediately "
714 "before an opening brace to force it to be interpreted as a hash reference "
715 "constructor expression. It is considered good style to use these "
716 "disambiguating mechanisms liberally, not only when Perl would otherwise "
717 "guess incorrectly."
718 msgstr ""
719
720 #. type: Plain text
721 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
722 #: opensuse-leap-16-1 opensuse-tumbleweed
723 msgid "The following compound statements may be used to control flow:"
724 msgstr ""
725
726 #. type: Plain text
727 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
728 #: opensuse-leap-16-1 opensuse-tumbleweed
729 #, no-wrap
730 msgid ""
731 "\\& if (EXPR) BLOCK\n"
732 "\\& if (EXPR) BLOCK else BLOCK\n"
733 "\\& if (EXPR) BLOCK elsif (EXPR) BLOCK ...\n"
734 "\\& if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK\n"
735 "\\&\n"
736 "\\& unless (EXPR) BLOCK\n"
737 "\\& unless (EXPR) BLOCK else BLOCK\n"
738 "\\& unless (EXPR) BLOCK elsif (EXPR) BLOCK ...\n"
739 "\\& unless (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK\n"
740 "\\&\n"
741 "\\& given (EXPR) BLOCK\n"
742 "\\&\n"
743 "\\& LABEL while (EXPR) BLOCK\n"
744 "\\& LABEL while (EXPR) BLOCK continue BLOCK\n"
745 "\\&\n"
746 "\\& LABEL until (EXPR) BLOCK\n"
747 "\\& LABEL until (EXPR) BLOCK continue BLOCK\n"
748 "\\&\n"
749 "\\& LABEL for (EXPR; EXPR; EXPR) BLOCK\n"
750 "\\& LABEL for VAR (LIST) BLOCK\n"
751 "\\& LABEL for VAR (LIST) BLOCK continue BLOCK\n"
752 "\\&\n"
753 "\\& LABEL foreach (EXPR; EXPR; EXPR) BLOCK\n"
754 "\\& LABEL foreach VAR (LIST) BLOCK\n"
755 "\\& LABEL foreach VAR (LIST) BLOCK continue BLOCK\n"
756 "\\&\n"
757 "\\& LABEL BLOCK\n"
758 "\\& LABEL BLOCK continue BLOCK\n"
759 "\\&\n"
760 "\\& PHASE BLOCK\n"
761 msgstr ""
762
763 #. type: Plain text
764 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
765 #: opensuse-leap-16-1 opensuse-tumbleweed
766 msgid ""
767 "As of Perl 5.36, you can iterate over multiple values at a time by "
768 "specifying a list of lexicals within parentheses:"
769 msgstr ""
770
771 #. type: Plain text
772 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
773 #: opensuse-leap-16-1 opensuse-tumbleweed
774 #, no-wrap
775 msgid ""
776 "\\& LABEL for my (VAR, VAR) (LIST) BLOCK\n"
777 "\\& LABEL for my (VAR, VAR) (LIST) BLOCK continue BLOCK\n"
778 "\\& LABEL foreach my (VAR, VAR) (LIST) BLOCK\n"
779 "\\& LABEL foreach my (VAR, VAR) (LIST) BLOCK continue BLOCK\n"
780 msgstr ""
781
782 #. type: Plain text
783 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
784 #: opensuse-leap-16-1 opensuse-tumbleweed
785 msgid ""
786 "If enabled by the CW<\\*(C`try\\*(C'> feature, the following may also be used"
787 msgstr ""
788
789 #. type: Plain text
790 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
791 #: opensuse-leap-16-1 opensuse-tumbleweed
792 #, no-wrap
793 msgid ""
794 "\\& try BLOCK catch (VAR) BLOCK\n"
795 "\\& try BLOCK catch (VAR) BLOCK finally BLOCK\n"
796 msgstr ""
797
798 #. type: Plain text
799 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
800 #: opensuse-leap-16-1 opensuse-tumbleweed
801 msgid ""
802 "The experimental CW<\\*(C`given\\*(C'> statement is I<not automatically "
803 "enabled>; see \"Switch Statements\" below for how to do so, and the "
804 "attendant caveats."
805 msgstr ""
806
807 #. type: Plain text
808 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
809 #: opensuse-leap-16-1 opensuse-tumbleweed
810 msgid ""
811 "Unlike in C and Pascal, in Perl these are all defined in terms of BLOCKs, "
812 "not statements. This means that the curly brackets are I<required>--no "
813 "dangling statements allowed. If you want to write conditionals without "
814 "curly brackets, there are several other ways to do it. The following all do "
815 "the same thing:"
816 msgstr ""
817
818 #. type: Plain text
819 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
820 #: opensuse-leap-16-1 opensuse-tumbleweed
821 #, no-wrap
822 msgid ""
823 "\\& if (!open(FOO)) { die \"Can\\*(Aqt open $FOO: $!\" }\n"
824 "\\& die \"Can\\*(Aqt open $FOO: $!\" unless open(FOO);\n"
825 "\\& open(FOO) || die \"Can\\*(Aqt open $FOO: $!\";\n"
826 "\\& open(FOO) ? () : die \"Can\\*(Aqt open $FOO: $!\";\n"
827 "\\& # a bit exotic, that last one\n"
828 msgstr ""
829
830 #. type: Plain text
831 #: debian-trixie debian-unstable
832 msgid ""
833 "The CW<\\*(C`if\\*(C'> statement is straightforward. Because BLOCKs are "
834 "always bounded by curly brackets, there is never any ambiguity about which "
835 "\\&CW<\\*(C`if\\*(C'> an CW<\\*(C`else\\*(C'> goes with. If you use "
836 "CW<\\*(C`unless\\*(C'> in place of CW<\\*(C`if\\*(C'>, the sense of the test "
837 "is reversed. Like CW<\\*(C`if\\*(C'>, CW<\\*(C`unless\\*(C'> can be "
838 "followed by CW<\\*(C`else\\*(C'>. CW<\\*(C`unless\\*(C'> can even be "
839 "followed by one or more CW<\\*(C`elsif\\*(C'> statements, though you may "
840 "want to think twice before using that particular language construct, as "
841 "everyone reading your code will have to think at least twice before they can "
842 "understand what's going on."
843 msgstr ""
844
845 #. type: Plain text
846 #: debian-trixie debian-unstable
847 msgid ""
848 "The CW<\\*(C`while\\*(C'> statement executes the block as long as the "
849 "expression is true. The CW<\\*(C`until\\*(C'> statement executes the block "
850 "as long as the expression is false. The LABEL is optional, and if present, "
851 "consists of an identifier followed by a colon. The LABEL identifies the "
852 "loop for the loop control statements CW<\\*(C`next\\*(C'>, "
853 "CW<\\*(C`last\\*(C'>, and CW<\\*(C`redo\\*(C'>. If the LABEL is omitted, "
854 "the loop control statement refers to the innermost enclosing loop. This may "
855 "include dynamically searching through your call-stack at run time to find "
856 "the LABEL. Such desperate behavior triggers a warning if you use the "
857 "CW<\\*(C`use warnings\\*(C'> pragma or the B<-w> flag."
858 msgstr ""
859
860 #. type: Plain text
861 #: debian-trixie debian-unstable
862 msgid ""
863 "If the condition expression of a CW<\\*(C`while\\*(C'> statement is based on "
864 "any of a group of iterative expression types then it gets some magic "
865 "treatment. The affected iterative expression types are "
866 "CW<\\*(C`readline\\*(C'>, the CW<\\*(C`E<lt>FILEHANDLEE<gt>\\*(C'> input "
867 "operator, CW<\\*(C`readdir\\*(C'>, CW<\\*(C`glob\\*(C'>, the "
868 "CW<\\*(C`E<lt>PATTERNE<gt>\\*(C'> globbing operator, and "
869 "CW<\\*(C`each\\*(C'>. If the condition expression is one of these "
870 "expression types, then the value yielded by the iterative operator will be "
871 "implicitly assigned to CW<$_>. If the condition expression is one of these "
872 "expression types or an explicit assignment of one of them to a scalar, then "
873 "the condition actually tests for definedness of the expression's value, not "
874 "for its regular truth value."
875 msgstr ""
876
877 #. type: Plain text
878 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
879 #: opensuse-leap-16-1 opensuse-tumbleweed
880 msgid ""
881 "If there is a CW<\\*(C`continue\\*(C'> BLOCK, it is always executed just "
882 "before the conditional is about to be evaluated again. Thus it can be used "
883 "to increment a loop variable, even when the loop has been continued via the "
884 "CW<\\*(C`next\\*(C'> statement."
885 msgstr ""
886
887 #. type: Plain text
888 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
889 #: opensuse-leap-16-1 opensuse-tumbleweed
890 msgid ""
891 "When a block is preceded by a compilation phase keyword such as "
892 "CW<\\*(C`BEGIN\\*(C'>, \\&CW<\\*(C`END\\*(C'>, CW<\\*(C`INIT\\*(C'>, "
893 "CW<\\*(C`CHECK\\*(C'>, or CW<\\*(C`UNITCHECK\\*(C'>, then the block will run "
894 "only during the corresponding phase of execution. See perlmod for more "
895 "details."
896 msgstr ""
897
898 #. type: Plain text
899 #: debian-trixie debian-unstable
900 msgid ""
901 "Extension modules can also hook into the Perl parser to define new kinds of "
902 "compound statements. These are introduced by a keyword which the extension "
903 "recognizes, and the syntax following the keyword is defined entirely by the "
904 "extension. If you are an implementor, see \"PL_keyword_plugin\" in perlapi "
905 "for the mechanism. If you are using such a module, see the module's "
906 "documentation for details of the syntax that it defines."
907 msgstr ""
908
909 #. type: IX
910 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
911 #: opensuse-leap-16-1 opensuse-tumbleweed
912 #, no-wrap
913 msgid "Loop Control"
914 msgstr ""
915
916 #. type: IX
917 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
918 #: opensuse-leap-16-1 opensuse-tumbleweed
919 #, no-wrap
920 msgid "loop control loop, control next last redo continue"
921 msgstr ""
922
923 #. type: Plain text
924 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
925 #: opensuse-leap-16-1 opensuse-tumbleweed
926 msgid "The CW<\\*(C`next\\*(C'> command starts the next iteration of the loop:"
927 msgstr ""
928
929 #. type: Plain text
930 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
931 #: opensuse-leap-16-1 opensuse-tumbleweed
932 #, no-wrap
933 msgid ""
934 "\\& LINE: while (E<lt>STDINE<gt>) {\n"
935 "\\& next LINE if /^#/; # discard comments\n"
936 "\\& ...\n"
937 "\\& }\n"
938 msgstr ""
939
940 #. type: Plain text
941 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
942 #: opensuse-leap-16-1 opensuse-tumbleweed
943 msgid ""
944 "The CW<\\*(C`last\\*(C'> command immediately exits the loop in question. "
945 "The \\&CW<\\*(C`continue\\*(C'> block, if any, is not executed:"
946 msgstr ""
947
948 #. type: Plain text
949 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
950 #: opensuse-leap-16-1 opensuse-tumbleweed
951 #, no-wrap
952 msgid ""
953 "\\& LINE: while (E<lt>STDINE<gt>) {\n"
954 "\\& last LINE if /^$/; # exit when done with header\n"
955 "\\& ...\n"
956 "\\& }\n"
957 msgstr ""
958
959 #. type: Plain text
960 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
961 #: opensuse-leap-16-1 opensuse-tumbleweed
962 msgid ""
963 "The CW<\\*(C`redo\\*(C'> command restarts the loop block without evaluating "
964 "the conditional again. The CW<\\*(C`continue\\*(C'> block, if any, is "
965 "I<not> executed. This command is normally used by programs that want to lie "
966 "to themselves about what was just input."
967 msgstr ""
968
969 #. type: Plain text
970 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
971 #: opensuse-leap-16-1 opensuse-tumbleweed
972 msgid ""
973 "For example, when processing a file like I</etc/termcap>. If your input "
974 "lines might end in backslashes to indicate continuation, you want to skip "
975 "ahead and get the next record."
976 msgstr ""
977
978 #. type: Plain text
979 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
980 #: opensuse-leap-16-1 opensuse-tumbleweed
981 #, no-wrap
982 msgid ""
983 "\\& while (E<lt>E<gt>) {\n"
984 "\\& chomp;\n"
985 "\\& if (s/\\e\\e$//) {\n"
986 "\\& $_ .= E<lt>E<gt>;\n"
987 "\\& redo unless eof();\n"
988 "\\& }\n"
989 "\\& # now process $_\n"
990 "\\& }\n"
991 msgstr ""
992
993 #. type: Plain text
994 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
995 #: opensuse-leap-16-1 opensuse-tumbleweed
996 msgid "which is Perl shorthand for the more explicitly written version:"
997 msgstr ""
998
999 #. type: Plain text
1000 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1001 #: opensuse-leap-16-1 opensuse-tumbleweed
1002 #, no-wrap
1003 msgid ""
1004 "\\& LINE: while (defined($line = E<lt>ARGVE<gt>)) {\n"
1005 "\\& chomp($line);\n"
1006 "\\& if ($line =~ s/\\e\\e$//) {\n"
1007 "\\& $line .= E<lt>ARGVE<gt>;\n"
1008 "\\& redo LINE unless eof(); # not eof(ARGV)!\n"
1009 "\\& }\n"
1010 "\\& # now process $line\n"
1011 "\\& }\n"
1012 msgstr ""
1013
1014 #. type: Plain text
1015 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1016 #: opensuse-leap-16-1 opensuse-tumbleweed
1017 msgid ""
1018 "Note that if there were a CW<\\*(C`continue\\*(C'> block on the above code, "
1019 "it would get executed only on lines discarded by the regex (since redo skips "
1020 "the continue block). A continue block is often used to reset line counters "
1021 "or CW<\\*(C`m?pat?\\*(C'> one-time matches:"
1022 msgstr ""
1023
1024 #. type: Plain text
1025 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1026 #: opensuse-leap-16-1 opensuse-tumbleweed
1027 #, no-wrap
1028 msgid ""
1029 "\\& # inspired by :1,$g/fred/s//WILMA/\n"
1030 "\\& while (E<lt>E<gt>) {\n"
1031 "\\& m?(fred)? && s//WILMA $1 WILMA/;\n"
1032 "\\& m?(barney)? && s//BETTY $1 BETTY/;\n"
1033 "\\& m?(homer)? && s//MARGE $1 MARGE/;\n"
1034 "\\& } continue {\n"
1035 "\\& print \"$ARGV $.: $_\";\n"
1036 "\\& close ARGV if eof; # reset $.\n"
1037 "\\& reset if eof; # reset ?pat?\n"
1038 "\\& }\n"
1039 msgstr ""
1040
1041 #. type: Plain text
1042 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1043 #: opensuse-leap-16-1 opensuse-tumbleweed
1044 msgid ""
1045 "If the word CW<\\*(C`while\\*(C'> is replaced by the word "
1046 "CW<\\*(C`until\\*(C'>, the sense of the test is reversed, but the "
1047 "conditional is still tested before the first iteration."
1048 msgstr ""
1049
1050 #. type: Plain text
1051 #: debian-trixie debian-unstable
1052 msgid ""
1053 "Loop control statements don't work in an CW<\\*(C`if\\*(C'> or "
1054 "CW<\\*(C`unless\\*(C'>, since they aren't loops. You can double the braces "
1055 "to make them such, though."
1056 msgstr ""
1057
1058 #. type: Plain text
1059 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1060 #: opensuse-leap-16-1 opensuse-tumbleweed
1061 #, no-wrap
1062 msgid ""
1063 "\\& if (/pattern/) {{\n"
1064 "\\& last if /fred/;\n"
1065 "\\& next if /barney/; # same effect as \"last\",\n"
1066 "\\& # but doesn\\*(Aqt document as well\n"
1067 "\\& # do something here\n"
1068 "\\& }}\n"
1069 msgstr ""
1070
1071 #. type: Plain text
1072 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1073 #: opensuse-leap-16-1 opensuse-tumbleweed
1074 msgid ""
1075 "This is caused by the fact that a block by itself acts as a loop that "
1076 "executes once, see \"Basic BLOCKs\"."
1077 msgstr ""
1078
1079 #. type: Plain text
1080 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1081 #: opensuse-leap-16-1 opensuse-tumbleweed
1082 msgid ""
1083 "The form CW<\\*(C`while/if BLOCK BLOCK\\*(C'>, available in Perl 4, is no "
1084 "longer available. Replace any occurrence of CW<\\*(C`if BLOCK\\*(C'> by "
1085 "CW<\\*(C`if (do BLOCK)\\*(C'>."
1086 msgstr ""
1087
1088 #. type: IX
1089 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1090 #: opensuse-leap-16-1 opensuse-tumbleweed
1091 #, no-wrap
1092 msgid "For Loops"
1093 msgstr ""
1094
1095 #. type: IX
1096 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1097 #: opensuse-leap-16-1 opensuse-tumbleweed
1098 #, no-wrap
1099 msgid "for foreach"
1100 msgstr ""
1101
1102 #. type: Plain text
1103 #: debian-trixie debian-unstable
1104 msgid ""
1105 "Perl's C-style CW<\\*(C`for\\*(C'> loop works like the corresponding "
1106 "CW<\\*(C`while\\*(C'> loop; that means that this:"
1107 msgstr ""
1108
1109 #. type: Plain text
1110 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1111 #: opensuse-leap-16-1 opensuse-tumbleweed
1112 #, no-wrap
1113 msgid ""
1114 "\\& for ($i = 1; $i E<lt> 10; $i++) {\n"
1115 "\\& ...\n"
1116 "\\& }\n"
1117 msgstr ""
1118
1119 #. type: Plain text
1120 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1121 #: opensuse-leap-16-1 opensuse-tumbleweed
1122 msgid "is the same as this:"
1123 msgstr ""
1124
1125 #. type: Plain text
1126 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1127 #: opensuse-leap-16-1 opensuse-tumbleweed
1128 #, no-wrap
1129 msgid ""
1130 "\\& $i = 1;\n"
1131 "\\& while ($i E<lt> 10) {\n"
1132 "\\& ...\n"
1133 "\\& } continue {\n"
1134 "\\& $i++;\n"
1135 "\\& }\n"
1136 msgstr ""
1137
1138 #. type: Plain text
1139 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1140 #: opensuse-leap-16-1 opensuse-tumbleweed
1141 msgid ""
1142 "There is one minor difference: if variables are declared with "
1143 "CW<\\*(C`my\\*(C'> in the initialization section of the CW<\\*(C`for\\*(C'>, "
1144 "the lexical scope of those variables is exactly the CW<\\*(C`for\\*(C'> loop "
1145 "(the body of the loop and the control sections). To illustrate:"
1146 msgstr ""
1147
1148 #. type: Plain text
1149 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1150 #: opensuse-leap-16-1 opensuse-tumbleweed
1151 #, no-wrap
1152 msgid ""
1153 "\\& my $i = \\*(Aqsamba\\*(Aq;\n"
1154 "\\& for (my $i = 1; $i E<lt>= 4; $i++) {\n"
1155 "\\& print \"$i\\en\";\n"
1156 "\\& }\n"
1157 "\\& print \"$i\\en\";\n"
1158 msgstr ""
1159
1160 #. type: Plain text
1161 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1162 #: opensuse-leap-16-1 opensuse-tumbleweed
1163 msgid "when executed, gives:"
1164 msgstr ""
1165
1166 #. type: Plain text
1167 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1168 #: opensuse-leap-16-1 opensuse-tumbleweed
1169 #, no-wrap
1170 msgid ""
1171 "\\& 1\n"
1172 "\\& 2\n"
1173 "\\& 3\n"
1174 "\\& 4\n"
1175 "\\& samba\n"
1176 msgstr ""
1177
1178 #. type: Plain text
1179 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1180 #: opensuse-leap-16-1 opensuse-tumbleweed
1181 msgid ""
1182 "As a special case, if the test in the CW<\\*(C`for\\*(C'> loop (or the "
1183 "corresponding \\&CW<\\*(C`while\\*(C'> loop) is empty, it is treated as "
1184 "true. That is, both"
1185 msgstr ""
1186
1187 #. type: Plain text
1188 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1189 #: opensuse-leap-16-1 opensuse-tumbleweed
1190 #, no-wrap
1191 msgid ""
1192 "\\& for (;;) {\n"
1193 "\\& ...\n"
1194 "\\& }\n"
1195 msgstr ""
1196
1197 #. type: Plain text
1198 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1199 #: opensuse-leap-16-1 opensuse-tumbleweed
1200 msgid "and"
1201 msgstr ""
1202
1203 #. type: Plain text
1204 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1205 #: opensuse-leap-16-1 opensuse-tumbleweed
1206 #, no-wrap
1207 msgid ""
1208 "\\& while () {\n"
1209 "\\& ...\n"
1210 "\\& }\n"
1211 msgstr ""
1212
1213 #. type: Plain text
1214 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1215 #: opensuse-leap-16-1 opensuse-tumbleweed
1216 msgid "are treated as infinite loops."
1217 msgstr ""
1218
1219 #. type: Plain text
1220 #: debian-trixie debian-unstable
1221 msgid ""
1222 "Besides the normal array index looping, CW<\\*(C`for\\*(C'> can lend itself "
1223 "to many other interesting applications. Here's one that avoids the problem "
1224 "you get into if you explicitly test for end-of-file on an interactive file "
1225 "descriptor causing your program to appear to hang."
1226 msgstr ""
1227
1228 #. type: IX
1229 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1230 #: opensuse-leap-16-1 opensuse-tumbleweed
1231 #, no-wrap
1232 msgid "eof end-of-file end of file"
1233 msgstr ""
1234
1235 #. type: Plain text
1236 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1237 #: opensuse-leap-16-1 opensuse-tumbleweed
1238 #, no-wrap
1239 msgid ""
1240 "\\& $on_a_tty = -t STDIN && -t STDOUT;\n"
1241 "\\& sub prompt { print \"yes? \" if $on_a_tty }\n"
1242 "\\& for ( prompt(); E<lt>STDINE<gt>; prompt() ) {\n"
1243 "\\& # do something\n"
1244 "\\& }\n"
1245 msgstr ""
1246
1247 #. type: Plain text
1248 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1249 #: opensuse-leap-16-1 opensuse-tumbleweed
1250 msgid ""
1251 "The condition expression of a CW<\\*(C`for\\*(C'> loop gets the same magic "
1252 "treatment of \\&CW<\\*(C`readline\\*(C'> et al that the condition expression "
1253 "of a CW<\\*(C`while\\*(C'> loop gets."
1254 msgstr ""
1255
1256 #. type: IX
1257 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1258 #: opensuse-leap-16-1 opensuse-tumbleweed
1259 #, no-wrap
1260 msgid "Foreach Loops"
1261 msgstr ""
1262
1263 #. type: Plain text
1264 #: debian-trixie debian-unstable
1265 msgid ""
1266 "The CW<\\*(C`foreach\\*(C'> loop iterates over a normal list value and sets "
1267 "the scalar variable VAR to be each element of the list in turn. If the "
1268 "variable is preceded with the keyword CW<\\*(C`my\\*(C'>, then it is "
1269 "lexically scoped, and is therefore visible only within the loop. Otherwise, "
1270 "the variable is implicitly local to the loop and regains its former value "
1271 "upon exiting the loop. If the variable was previously declared with "
1272 "CW<\\*(C`my\\*(C'>, it uses that variable instead of the global one, but "
1273 "it's still localized to the loop. This implicit localization occurs I<only> "
1274 "for non C-style loops."
1275 msgstr ""
1276
1277 #. type: IX
1278 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1279 #: opensuse-leap-16-1 opensuse-tumbleweed
1280 #, no-wrap
1281 msgid "my local"
1282 msgstr ""
1283
1284 #. type: Plain text
1285 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1286 #: opensuse-leap-16-1 opensuse-tumbleweed
1287 msgid ""
1288 "The CW<\\*(C`foreach\\*(C'> keyword is actually a synonym for the "
1289 "CW<\\*(C`for\\*(C'> keyword, so you can use either. If VAR is omitted, "
1290 "CW<$_> is set to each value."
1291 msgstr ""
1292
1293 #. type: IX
1294 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1295 #: opensuse-leap-16-1 opensuse-tumbleweed
1296 #, no-wrap
1297 msgid "$_"
1298 msgstr ""
1299
1300 #. type: Plain text
1301 #: debian-trixie debian-unstable
1302 msgid ""
1303 "If any element of LIST is an lvalue, you can modify it by modifying VAR "
1304 "inside the loop. Conversely, if any element of LIST is NOT an lvalue, any "
1305 "attempt to modify that element will fail. In other words, the "
1306 "CW<\\*(C`foreach\\*(C'> loop index variable is an implicit alias for each "
1307 "item in the list that you're looping over."
1308 msgstr ""
1309
1310 #. type: IX
1311 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1312 #: opensuse-leap-16-1 opensuse-tumbleweed
1313 #, no-wrap
1314 msgid "alias"
1315 msgstr ""
1316
1317 #. type: Plain text
1318 #: debian-trixie debian-unstable
1319 msgid ""
1320 "If any part of LIST is an array, CW<\\*(C`foreach\\*(C'> will get very "
1321 "confused if you add or remove elements within the loop body, for example "
1322 "with \\&CW<\\*(C`splice\\*(C'>. So don't do that."
1323 msgstr ""
1324
1325 #. type: IX
1326 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1327 #: opensuse-leap-16-1 opensuse-tumbleweed
1328 #, no-wrap
1329 msgid "splice"
1330 msgstr ""
1331
1332 #. type: Plain text
1333 #: debian-trixie debian-unstable
1334 msgid ""
1335 "\\&CW<\\*(C`foreach\\*(C'> probably won't do what you expect if VAR is a "
1336 "tied or other special variable. Don't do that either."
1337 msgstr ""
1338
1339 #. type: Plain text
1340 #: debian-trixie debian-unstable
1341 msgid ""
1342 "As of Perl 5.22, there is an experimental variant of this loop that accepts "
1343 "a variable preceded by a backslash for VAR, in which case the items in the "
1344 "LIST must be references. The backslashed variable will become an alias to "
1345 "each referenced item in the LIST, which must be of the correct type. The "
1346 "variable needn't be a scalar in this case, and the backslash may be followed "
1347 "by CW<\\*(C`my\\*(C'>. To use this form, you must enable the "
1348 "CW<\\*(C`refaliasing\\*(C'> feature via CW<\\*(C`use feature\\*(C'>. (See "
1349 "feature. See also \"Assigning to References\" in perlref.)"
1350 msgstr ""
1351
1352 #. type: Plain text
1353 #: debian-trixie debian-unstable
1354 msgid ""
1355 "As of Perl 5.36, you can iterate over multiple values at a time. You can "
1356 "only iterate with lexical scalars as the iterator variables - unlike list "
1357 "assignment, it's not possible to use CW<\\*(C`undef\\*(C'> to signify a "
1358 "value that isn't wanted. This is a limitation of the current "
1359 "implementation, and might be changed in the future."
1360 msgstr ""
1361
1362 #. type: Plain text
1363 #: debian-trixie debian-unstable
1364 msgid ""
1365 "If the size of the LIST is not an exact multiple of the number of iterator "
1366 "variables, then on the last iteration the \"excess\" iterator variables are "
1367 "aliases to CW<\\*(C`undef\\*(C'>, as if the LIST had CW<\\*(C`, undef\\*(C'> "
1368 "appended as many times as needed for its length to become an exact "
1369 "multiple. This happens whether LIST is a literal LIST or an array - ie "
1370 "arrays are not extended if their size is not a multiple of the iteration "
1371 "size, consistent with iterating an array one-at-a-time. As these padding "
1372 "elements are not lvalues, attempting to modify them will fail, consistent "
1373 "with the behaviour when iterating a list with literal "
1374 "CW<\\*(C`undef\\*(C'>s. If this is not the behaviour you desire, then "
1375 "before the loop starts either explicitly extend your array to be an exact "
1376 "multiple, or explicitly throw an exception."
1377 msgstr ""
1378
1379 #. type: Plain text
1380 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1381 #: opensuse-leap-16-1 opensuse-tumbleweed
1382 msgid "Examples:"
1383 msgstr ""
1384
1385 #. type: Plain text
1386 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1387 #: opensuse-leap-16-1 opensuse-tumbleweed
1388 #, no-wrap
1389 msgid ""
1390 "\\& for (@ary) { s/foo/bar/ }\n"
1391 "\\&\n"
1392 "\\& for my $elem (@elements) {\n"
1393 "\\& $elem *= 2;\n"
1394 "\\& }\n"
1395 "\\&\n"
1396 "\\& for $count (reverse(1..10), \"BOOM\") {\n"
1397 "\\& print $count, \"\\en\";\n"
1398 "\\& sleep(1);\n"
1399 "\\& }\n"
1400 "\\&\n"
1401 "\\& for (1..15) { print \"Merry Christmas\\en\"; }\n"
1402 "\\&\n"
1403 "\\& foreach $item (split(/:[\\e\\e\\en:]*/, $ENV{TERMCAP})) {\n"
1404 "\\& print \"Item: $item\\en\";\n"
1405 "\\& }\n"
1406 "\\&\n"
1407 "\\& use feature \"refaliasing\";\n"
1408 "\\& no warnings \"experimental::refaliasing\";\n"
1409 "\\& foreach \\emy %hash (@array_of_hash_references) {\n"
1410 "\\& # do something with each %hash\n"
1411 "\\& }\n"
1412 "\\&\n"
1413 "\\& foreach my ($foo, $bar, $baz) (@list) {\n"
1414 "\\& # do something three-at-a-time\n"
1415 "\\& }\n"
1416 "\\&\n"
1417 "\\& foreach my ($key, $value) (%hash) {\n"
1418 "\\& # iterate over the hash\n"
1419 "\\& # The hash is immediately copied to a flat list before the loop\n"
1420 "\\& # starts. The list contains copies of keys but aliases of values.\n"
1421 "\\& # This is the same behaviour as for $var (%hash) {...}\n"
1422 "\\& }\n"
1423 msgstr ""
1424
1425 #. type: Plain text
1426 #: debian-trixie debian-unstable
1427 msgid "Here's how a C programmer might code up a particular algorithm in Perl:"
1428 msgstr ""
1429
1430 #. type: Plain text
1431 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1432 #: opensuse-leap-16-1 opensuse-tumbleweed
1433 #, no-wrap
1434 msgid ""
1435 "\\& for (my $i = 0; $i E<lt> @ary1; $i++) {\n"
1436 "\\& for (my $j = 0; $j E<lt> @ary2; $j++) {\n"
1437 "\\& if ($ary1[$i] E<gt> $ary2[$j]) {\n"
1438 "\\& last; # can\\*(Aqt go to outer :-(\n"
1439 "\\& }\n"
1440 "\\& $ary1[$i] += $ary2[$j];\n"
1441 "\\& }\n"
1442 "\\& # this is where that last takes me\n"
1443 "\\& }\n"
1444 msgstr ""
1445
1446 #. type: Plain text
1447 #: debian-trixie debian-unstable
1448 msgid ""
1449 "Whereas here's how a Perl programmer more comfortable with the idiom might "
1450 "do it:"
1451 msgstr ""
1452
1453 #. type: Plain text
1454 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1455 #: opensuse-leap-16-1 opensuse-tumbleweed
1456 #, no-wrap
1457 msgid ""
1458 "\\& OUTER: for my $wid (@ary1) {\n"
1459 "\\& INNER: for my $jet (@ary2) {\n"
1460 "\\& next OUTER if $wid E<gt> $jet;\n"
1461 "\\& $wid += $jet;\n"
1462 "\\& }\n"
1463 "\\& }\n"
1464 msgstr ""
1465
1466 #. type: Plain text
1467 #: debian-trixie debian-unstable
1468 msgid ""
1469 "See how much easier this is? It's cleaner, safer, and faster. It's cleaner "
1470 "because it's less noisy. It's safer because if code gets added between the "
1471 "inner and outer loops later on, the new code won't be accidentally "
1472 "executed. The CW<\\*(C`next\\*(C'> explicitly iterates the other loop "
1473 "rather than merely terminating the inner one. And it's faster because Perl "
1474 "executes a CW<\\*(C`foreach\\*(C'> statement more rapidly than it would the "
1475 "equivalent C-style CW<\\*(C`for\\*(C'> loop."
1476 msgstr ""
1477
1478 #. type: Plain text
1479 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1480 #: opensuse-leap-16-1 opensuse-tumbleweed
1481 msgid ""
1482 "Perceptive Perl hackers may have noticed that a CW<\\*(C`for\\*(C'> loop has "
1483 "a return value, and that this value can be captured by wrapping the loop in "
1484 "a CW<\\*(C`do\\*(C'> block. The reward for this discovery is this "
1485 "cautionary advice: The return value of a CW<\\*(C`for\\*(C'> loop is "
1486 "unspecified and may change without notice. Do not rely on it."
1487 msgstr ""
1488
1489 #. type: IX
1490 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1491 #: opensuse-leap-16-1 opensuse-tumbleweed
1492 #, no-wrap
1493 msgid "Try Catch Exception Handling"
1494 msgstr ""
1495
1496 #. type: IX
1497 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1498 #: opensuse-leap-16-1 opensuse-tumbleweed
1499 #, no-wrap
1500 msgid "try catch finally"
1501 msgstr ""
1502
1503 #. type: Plain text
1504 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1505 #: opensuse-leap-16-1 opensuse-tumbleweed
1506 msgid ""
1507 "The CW<\\*(C`try\\*(C'>/CW<\\*(C`catch\\*(C'> syntax provides control flow "
1508 "relating to exception handling. The CW<\\*(C`try\\*(C'> keyword introduces a "
1509 "block which will be executed when it is encountered, and the "
1510 "CW<\\*(C`catch\\*(C'> block provides code to handle any exception that may "
1511 "be thrown by the first."
1512 msgstr ""
1513
1514 #. type: Plain text
1515 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1516 #: opensuse-leap-16-1 opensuse-tumbleweed
1517 msgid ""
1518 "This syntax must first be enabled with CW<\\*(C`use feature "
1519 "\\*(Aqtry\\*(Aq\\*(C'>."
1520 msgstr ""
1521
1522 #. type: Plain text
1523 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1524 #: opensuse-leap-16-1 opensuse-tumbleweed
1525 #, no-wrap
1526 msgid ""
1527 "\\& use feature \\*(Aqtry\\*(Aq;\n"
1528 "\\&\n"
1529 "\\& try {\n"
1530 "\\& my $x = call_a_function();\n"
1531 "\\& $x E<lt> 100 or die \"Too big\";\n"
1532 "\\& send_output($x);\n"
1533 "\\& }\n"
1534 "\\& catch ($e) {\n"
1535 "\\& warn \"Unable to output a value; $e\";\n"
1536 "\\& }\n"
1537 "\\& print \"Finished\\en\";\n"
1538 msgstr ""
1539
1540 #. type: Plain text
1541 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1542 #: opensuse-leap-16-1 opensuse-tumbleweed
1543 msgid ""
1544 "Here, the body of the CW<\\*(C`catch\\*(C'> block (i.e. the "
1545 "CW<\\*(C`warn\\*(C'> statement) will be executed if the initial block "
1546 "invokes the conditional CW<\\*(C`die\\*(C'>, or if either of the functions "
1547 "it invokes throws an uncaught exception. The CW<\\*(C`catch\\*(C'> block can "
1548 "inspect the CW<$e> lexical variable in this case to see what the exception "
1549 "was. If no exception was thrown then the CW<\\*(C`catch\\*(C'> block does "
1550 "not happen. In either case, execution will then continue from the following "
1551 "statement - in this example the CW<\\*(C`print\\*(C'>."
1552 msgstr ""
1553
1554 #. type: Plain text
1555 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1556 #: opensuse-leap-16-1 opensuse-tumbleweed
1557 msgid ""
1558 "The CW<\\*(C`catch\\*(C'> keyword must be immediately followed by a variable "
1559 "declaration in parentheses, which introduces a new variable visible to the "
1560 "body of the subsequent block. Inside the block this variable will contain "
1561 "the exception value that was thrown by the code in the CW<\\*(C`try\\*(C'> "
1562 "block. It is not necessary to use the CW<\\*(C`my\\*(C'> keyword to declare "
1563 "this variable; this is implied (similar as it is for subroutine signatures)."
1564 msgstr ""
1565
1566 #. type: Plain text
1567 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1568 #: opensuse-leap-16-1 opensuse-tumbleweed
1569 msgid ""
1570 "Both the CW<\\*(C`try\\*(C'> and the CW<\\*(C`catch\\*(C'> blocks are "
1571 "permitted to contain control-flow expressions, such as "
1572 "CW<\\*(C`return\\*(C'>, CW<\\*(C`goto\\*(C'>, or CW<\\*(C`next\\*(C'>/"
1573 "CW<\\*(C`last\\*(C'>/CW<\\*(C`redo\\*(C'>. In all cases they behave as "
1574 "expected without warnings. In particular, a CW<\\*(C`return\\*(C'> "
1575 "expression inside the CW<\\*(C`try\\*(C'> block will make its entire "
1576 "containing function return - this is in contrast to its behaviour inside an "
1577 "CW<\\*(C`eval\\*(C'> block, where it would only make that block return."
1578 msgstr ""
1579
1580 #. type: Plain text
1581 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1582 #: opensuse-leap-16-1 opensuse-tumbleweed
1583 msgid ""
1584 "Like other control-flow syntax, CW<\\*(C`try\\*(C'> and "
1585 "CW<\\*(C`catch\\*(C'> will yield the last evaluated value when placed as the "
1586 "final statement in a function or a CW<\\*(C`do\\*(C'> block. This permits "
1587 "the syntax to be used to create a value. In this case remember not to use "
1588 "the CW<\\*(C`return\\*(C'> expression, or that will cause the containing "
1589 "function to return."
1590 msgstr ""
1591
1592 #. type: Plain text
1593 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1594 #: opensuse-leap-16-1 opensuse-tumbleweed
1595 #, no-wrap
1596 msgid ""
1597 "\\& my $value = do {\n"
1598 "\\& try {\n"
1599 "\\& get_thing(@args);\n"
1600 "\\& }\n"
1601 "\\& catch ($e) {\n"
1602 "\\& warn \"Unable to get thing - $e\";\n"
1603 "\\& $DEFAULT_THING;\n"
1604 "\\& }\n"
1605 "\\& };\n"
1606 msgstr ""
1607
1608 #. type: Plain text
1609 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1610 #: opensuse-leap-16-1 opensuse-tumbleweed
1611 msgid ""
1612 "As with other control-flow syntax, CW<\\*(C`try\\*(C'> blocks are not "
1613 "visible to \\&CW<caller()> (just as for example, CW<\\*(C`while\\*(C'> or "
1614 "CW<\\*(C`foreach\\*(C'> loops are not). Successive levels of the "
1615 "CW<\\*(C`caller\\*(C'> result can see subroutine calls and "
1616 "\\&CW<\\*(C`eval\\*(C'> blocks, because those affect the way that "
1617 "CW<\\*(C`return\\*(C'> would work. Since \\&CW<\\*(C`try\\*(C'> blocks do "
1618 "not intercept CW<\\*(C`return\\*(C'>, they are not of interest to "
1619 "\\&CW<\\*(C`caller\\*(C'>."
1620 msgstr ""
1621
1622 #. type: Plain text
1623 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1624 #: opensuse-leap-16-1 opensuse-tumbleweed
1625 msgid ""
1626 "The CW<\\*(C`try\\*(C'> and CW<\\*(C`catch\\*(C'> blocks may optionally be "
1627 "followed by a third block introduced by the CW<\\*(C`finally\\*(C'> keyword. "
1628 "This third block is executed after the rest of the construct has finished."
1629 msgstr ""
1630
1631 #. type: Plain text
1632 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1633 #: opensuse-leap-16-1 opensuse-tumbleweed
1634 #, no-wrap
1635 msgid ""
1636 "\\& try {\n"
1637 "\\& call_a_function();\n"
1638 "\\& }\n"
1639 "\\& catch ($e) {\n"
1640 "\\& warn \"Unable to call; $e\";\n"
1641 "\\& }\n"
1642 "\\& finally {\n"
1643 "\\& print \"Finished\\en\";\n"
1644 "\\& }\n"
1645 msgstr ""
1646
1647 #. type: Plain text
1648 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1649 #: opensuse-leap-16-1 opensuse-tumbleweed
1650 msgid ""
1651 "The CW<\\*(C`finally\\*(C'> block is equivalent to using a "
1652 "CW<\\*(C`defer\\*(C'> block and will be invoked in the same situations; "
1653 "whether the CW<\\*(C`try\\*(C'> block completes successfully, throws an "
1654 "exception, or transfers control elsewhere by using "
1655 "\\&CW<\\*(C`return\\*(C'>, a loop control, or CW<\\*(C`goto\\*(C'>."
1656 msgstr ""
1657
1658 #. type: Plain text
1659 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1660 #: opensuse-leap-16-1 opensuse-tumbleweed
1661 msgid ""
1662 "Unlike the CW<\\*(C`try\\*(C'> and CW<\\*(C`catch\\*(C'> blocks, a "
1663 "CW<\\*(C`finally\\*(C'> block is not permitted to \\&CW<\\*(C`return\\*(C'>, "
1664 "CW<\\*(C`goto\\*(C'> or use any loop controls. The final expression value is "
1665 "ignored, and does not affect the return value of the containing function "
1666 "even if it is placed last in the function."
1667 msgstr ""
1668
1669 #. type: Plain text
1670 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1671 #: opensuse-leap-16-1 opensuse-tumbleweed
1672 msgid ""
1673 "Use of this CW<\\*(C`finally\\*(C'> block syntax is currently experimental "
1674 "and will emit a warning in the CW<\\*(C`experimental::try\\*(C'> category."
1675 msgstr ""
1676
1677 #. type: IX
1678 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1679 #: opensuse-leap-16-1 opensuse-tumbleweed
1680 #, no-wrap
1681 msgid "Basic BLOCKs"
1682 msgstr ""
1683
1684 #. type: IX
1685 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1686 #: opensuse-leap-16-1 opensuse-tumbleweed
1687 #, no-wrap
1688 msgid "block"
1689 msgstr ""
1690
1691 #. type: Plain text
1692 #: debian-trixie debian-unstable
1693 msgid ""
1694 "A BLOCK by itself (labeled or not) is semantically equivalent to a loop that "
1695 "executes once. Thus you can use any of the loop control statements in it to "
1696 "leave or restart the block. (Note that this is \\&I<NOT> true in "
1697 "CW<\\*(C`eval{}\\*(C'>, CW<\\*(C`sub{}\\*(C'>, or contrary to popular belief "
1698 "\\&CW<\\*(C`do{}\\*(C'> blocks, which do I<NOT> count as loops.) The "
1699 "CW<\\*(C`continue\\*(C'> block is optional."
1700 msgstr ""
1701
1702 #. type: Plain text
1703 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1704 #: opensuse-leap-16-1 opensuse-tumbleweed
1705 msgid "The BLOCK construct can be used to emulate case structures."
1706 msgstr ""
1707
1708 #. type: Plain text
1709 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1710 #: opensuse-leap-16-1 opensuse-tumbleweed
1711 #, no-wrap
1712 msgid ""
1713 "\\& SWITCH: {\n"
1714 "\\& if (/^abc/) { $abc = 1; last SWITCH; }\n"
1715 "\\& if (/^def/) { $def = 1; last SWITCH; }\n"
1716 "\\& if (/^xyz/) { $xyz = 1; last SWITCH; }\n"
1717 "\\& $nothing = 1;\n"
1718 "\\& }\n"
1719 msgstr ""
1720
1721 #. type: Plain text
1722 #: debian-trixie debian-unstable
1723 msgid ""
1724 "You'll also find that CW<\\*(C`foreach\\*(C'> loop used to create a "
1725 "topicalizer and a switch:"
1726 msgstr ""
1727
1728 #. type: Plain text
1729 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1730 #: opensuse-leap-16-1 opensuse-tumbleweed
1731 #, no-wrap
1732 msgid ""
1733 "\\& SWITCH:\n"
1734 "\\& for ($var) {\n"
1735 "\\& if (/^abc/) { $abc = 1; last SWITCH; }\n"
1736 "\\& if (/^def/) { $def = 1; last SWITCH; }\n"
1737 "\\& if (/^xyz/) { $xyz = 1; last SWITCH; }\n"
1738 "\\& $nothing = 1;\n"
1739 "\\& }\n"
1740 msgstr ""
1741
1742 #. type: Plain text
1743 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1744 #: opensuse-leap-16-1 opensuse-tumbleweed
1745 msgid ""
1746 "Such constructs are quite frequently used, both because older versions of "
1747 "Perl had no official CW<\\*(C`switch\\*(C'> statement, and also because the "
1748 "new version described immediately below remains experimental and can "
1749 "sometimes be confusing."
1750 msgstr ""
1751
1752 #. type: IX
1753 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1754 #: opensuse-leap-16-1 opensuse-tumbleweed
1755 #, no-wrap
1756 msgid "defer blocks"
1757 msgstr ""
1758
1759 #. type: IX
1760 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1761 #: opensuse-leap-16-1 opensuse-tumbleweed
1762 #, no-wrap
1763 msgid "defer"
1764 msgstr ""
1765
1766 #. type: Plain text
1767 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1768 #: opensuse-leap-16-1 opensuse-tumbleweed
1769 msgid ""
1770 "A block prefixed by the CW<\\*(C`defer\\*(C'> modifier provides a section of "
1771 "code which runs at a later time during scope exit."
1772 msgstr ""
1773
1774 #. type: Plain text
1775 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1776 #: opensuse-leap-16-1 opensuse-tumbleweed
1777 msgid ""
1778 "A CW<\\*(C`defer\\*(C'> block can appear at any point where a regular block "
1779 "or other statement is permitted. If the flow of execution reaches this "
1780 "statement, the body of the block is stored for later, but not invoked "
1781 "immediately. When the flow of control leaves the containing block for any "
1782 "reason, this stored block is executed on the way past. It provides a means "
1783 "of deferring execution until a later time. This acts similarly to syntax "
1784 "provided by some other languages, often using keywords named CW<\\*(C`try / "
1785 "finally\\*(C'>."
1786 msgstr ""
1787
1788 #. type: Plain text
1789 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1790 #: opensuse-leap-16-1 opensuse-tumbleweed
1791 msgid ""
1792 "This syntax is available since Perl 5.36 if enabled by the "
1793 "CW<\\*(C`defer\\*(C'> named feature, and is currently experimental. If "
1794 "experimental warnings are enabled it will emit a warning when used."
1795 msgstr ""
1796
1797 #. type: Plain text
1798 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1799 #: opensuse-leap-16-1 opensuse-tumbleweed
1800 #, no-wrap
1801 msgid ""
1802 "\\& use feature \\*(Aqdefer\\*(Aq;\n"
1803 "\\&\n"
1804 "\\& {\n"
1805 "\\& say \"This happens first\";\n"
1806 "\\& defer { say \"This happens last\"; }\n"
1807 "\\&\n"
1808 "\\& say \"And this happens inbetween\";\n"
1809 "\\& }\n"
1810 msgstr ""
1811
1812 #. type: Plain text
1813 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1814 #: opensuse-leap-16-1 opensuse-tumbleweed
1815 msgid ""
1816 "If multiple CW<\\*(C`defer\\*(C'> blocks are contained in a single scope, "
1817 "they are executed in LIFO order; the last one reached is the first one "
1818 "executed."
1819 msgstr ""
1820
1821 #. type: Plain text
1822 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1823 #: opensuse-leap-16-1 opensuse-tumbleweed
1824 msgid ""
1825 "The code stored by the CW<\\*(C`defer\\*(C'> block will be invoked when "
1826 "control leaves its containing block due to regular fallthrough, explicit "
1827 "CW<\\*(C`return\\*(C'>, exceptions thrown by CW<\\*(C`die\\*(C'> or "
1828 "propagated by functions called by it, CW<\\*(C`goto\\*(C'>, or any of the "
1829 "loop control statements CW<\\*(C`next\\*(C'>, CW<\\*(C`last\\*(C'> or "
1830 "CW<\\*(C`redo\\*(C'>."
1831 msgstr ""
1832
1833 #. type: Plain text
1834 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1835 #: opensuse-leap-16-1 opensuse-tumbleweed
1836 msgid ""
1837 "If the flow of control does not reach the CW<\\*(C`defer\\*(C'> statement "
1838 "itself then its body is not stored for later execution. (This is in direct "
1839 "contrast to the code provided by an CW<\\*(C`END\\*(C'> phaser block, which "
1840 "is always enqueued by the compiler, regardless of whether execution ever "
1841 "reached the line it was given on.)"
1842 msgstr ""
1843
1844 #. type: Plain text
1845 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1846 #: opensuse-leap-16-1 opensuse-tumbleweed
1847 #, no-wrap
1848 msgid ""
1849 "\\& use feature \\*(Aqdefer\\*(Aq;\n"
1850 "\\&\n"
1851 "\\& {\n"
1852 "\\& defer { say \"This will run\"; }\n"
1853 "\\& return;\n"
1854 "\\& defer { say \"This will not\"; }\n"
1855 "\\& }\n"
1856 msgstr ""
1857
1858 #. type: Plain text
1859 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1860 #: opensuse-leap-16-1 opensuse-tumbleweed
1861 msgid ""
1862 "Exceptions thrown by code inside a CW<\\*(C`defer\\*(C'> block will "
1863 "propagate to the caller in the same way as any other exception thrown by "
1864 "normal code."
1865 msgstr ""
1866
1867 #. type: Plain text
1868 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1869 #: opensuse-leap-16-1 opensuse-tumbleweed
1870 msgid ""
1871 "If the CW<\\*(C`defer\\*(C'> block is being executed due to a thrown "
1872 "exception and throws another one it is not specified what happens, beyond "
1873 "that the caller will definitely receive an exception."
1874 msgstr ""
1875
1876 #. type: Plain text
1877 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1878 #: opensuse-leap-16-1 opensuse-tumbleweed
1879 msgid ""
1880 "Besides throwing an exception, a CW<\\*(C`defer\\*(C'> block is not "
1881 "permitted to otherwise alter the control flow of its surrounding code. In "
1882 "particular, it may not cause its containing function to "
1883 "CW<\\*(C`return\\*(C'>, nor may it CW<\\*(C`goto\\*(C'> a label, or control "
1884 "a containing loop using CW<\\*(C`next\\*(C'>, CW<\\*(C`last\\*(C'> or "
1885 "CW<\\*(C`redo\\*(C'>. These constructions are however, permitted entirely "
1886 "within the body of the \\&CW<\\*(C`defer\\*(C'>."
1887 msgstr ""
1888
1889 #. type: Plain text
1890 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1891 #: opensuse-leap-16-1 opensuse-tumbleweed
1892 #, no-wrap
1893 msgid ""
1894 "\\& use feature \\*(Aqdefer\\*(Aq;\n"
1895 "\\&\n"
1896 "\\& {\n"
1897 "\\& defer {\n"
1898 "\\& foreach ( 1 .. 5 ) {\n"
1899 "\\& last if $_ == 3; # this is permitted\n"
1900 "\\& }\n"
1901 "\\& }\n"
1902 "\\& }\n"
1903 "\\&\n"
1904 "\\& {\n"
1905 "\\& foreach ( 6 .. 10 ) {\n"
1906 "\\& defer {\n"
1907 "\\& last if $_ == 8; # this is not\n"
1908 "\\& }\n"
1909 "\\& }\n"
1910 "\\& }\n"
1911 msgstr ""
1912
1913 #. type: IX
1914 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1915 #: opensuse-leap-16-1 opensuse-tumbleweed
1916 #, no-wrap
1917 msgid "Switch Statements"
1918 msgstr ""
1919
1920 #. type: IX
1921 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1922 #: opensuse-leap-16-1 opensuse-tumbleweed
1923 #, no-wrap
1924 msgid "switch case given when default"
1925 msgstr ""
1926
1927 #. type: Plain text
1928 #: debian-trixie debian-unstable
1929 msgid ""
1930 "Starting from Perl 5.10.1 (well, 5.10.0, but it didn't work right), you can "
1931 "say"
1932 msgstr ""
1933
1934 #. type: Plain text
1935 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1936 #: opensuse-leap-16-1 opensuse-tumbleweed
1937 #, no-wrap
1938 msgid "\\& use feature \"switch\";\n"
1939 msgstr ""
1940
1941 #. type: Plain text
1942 #: debian-trixie debian-unstable
1943 msgid ""
1944 "to enable an experimental switch feature. This is loosely based on an old "
1945 "version of a Raku proposal, but it no longer resembles the Raku construct. "
1946 "You also get the switch feature whenever you declare that your code prefers "
1947 "to run under a version of Perl between 5.10 and 5.34. For example:"
1948 msgstr ""
1949
1950 #. type: Plain text
1951 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1952 #: opensuse-leap-16-1 opensuse-tumbleweed
1953 #, no-wrap
1954 msgid "\\& use v5.14;\n"
1955 msgstr ""
1956
1957 #. type: Plain text
1958 #: debian-trixie debian-unstable
1959 msgid ""
1960 "Under the \"switch\" feature, Perl gains the experimental keywords "
1961 "\\&CW<\\*(C`given\\*(C'>, CW<\\*(C`when\\*(C'>, CW<\\*(C`default\\*(C'>, "
1962 "CW<\\*(C`continue\\*(C'>, and CW<\\*(C`break\\*(C'>. Starting from Perl "
1963 "5.16, one can prefix the switch keywords with CW<\\*(C`CORE::\\*(C'> to "
1964 "access the feature without a CW<\\*(C`use feature\\*(C'> statement. The "
1965 "keywords CW<\\*(C`given\\*(C'> and \\&CW<\\*(C`when\\*(C'> are analogous to "
1966 "CW<\\*(C`switch\\*(C'> and \\&CW<\\*(C`case\\*(C'> in other languages -- "
1967 "though CW<\\*(C`continue\\*(C'> is not -- so the code in the previous "
1968 "section could be rewritten as"
1969 msgstr ""
1970
1971 #. type: Plain text
1972 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1973 #: opensuse-leap-16-1 opensuse-tumbleweed
1974 #, no-wrap
1975 msgid ""
1976 "\\& use v5.10.1;\n"
1977 "\\& for ($var) {\n"
1978 "\\& when (/^abc/) { $abc = 1 }\n"
1979 "\\& when (/^def/) { $def = 1 }\n"
1980 "\\& when (/^xyz/) { $xyz = 1 }\n"
1981 "\\& default { $nothing = 1 }\n"
1982 "\\& }\n"
1983 msgstr ""
1984
1985 #. type: Plain text
1986 #: debian-trixie debian-unstable
1987 msgid ""
1988 "The CW<\\*(C`foreach\\*(C'> is the non-experimental way to set a "
1989 "topicalizer. If you wish to use the highly experimental "
1990 "CW<\\*(C`given\\*(C'>, that could be written like this:"
1991 msgstr ""
1992
1993 #. type: Plain text
1994 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1995 #: opensuse-leap-16-1 opensuse-tumbleweed
1996 #, no-wrap
1997 msgid ""
1998 "\\& use v5.10.1;\n"
1999 "\\& given ($var) {\n"
2000 "\\& when (/^abc/) { $abc = 1 }\n"
2001 "\\& when (/^def/) { $def = 1 }\n"
2002 "\\& when (/^xyz/) { $xyz = 1 }\n"
2003 "\\& default { $nothing = 1 }\n"
2004 "\\& }\n"
2005 msgstr ""
2006
2007 #. type: Plain text
2008 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2009 #: opensuse-leap-16-1 opensuse-tumbleweed
2010 msgid "As of 5.14, that can also be written this way:"
2011 msgstr ""
2012
2013 #. type: Plain text
2014 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2015 #: opensuse-leap-16-1 opensuse-tumbleweed
2016 #, no-wrap
2017 msgid ""
2018 "\\& use v5.14;\n"
2019 "\\& for ($var) {\n"
2020 "\\& $abc = 1 when /^abc/;\n"
2021 "\\& $def = 1 when /^def/;\n"
2022 "\\& $xyz = 1 when /^xyz/;\n"
2023 "\\& default { $nothing = 1 }\n"
2024 "\\& }\n"
2025 msgstr ""
2026
2027 #. type: Plain text
2028 #: debian-trixie debian-unstable
2029 msgid "Or if you don't care to play it safe, like this:"
2030 msgstr ""
2031
2032 #. type: Plain text
2033 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2034 #: opensuse-leap-16-1 opensuse-tumbleweed
2035 #, no-wrap
2036 msgid ""
2037 "\\& use v5.14;\n"
2038 "\\& given ($var) {\n"
2039 "\\& $abc = 1 when /^abc/;\n"
2040 "\\& $def = 1 when /^def/;\n"
2041 "\\& $xyz = 1 when /^xyz/;\n"
2042 "\\& default { $nothing = 1 }\n"
2043 "\\& }\n"
2044 msgstr ""
2045
2046 #. type: Plain text
2047 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2048 #: opensuse-leap-16-1 opensuse-tumbleweed
2049 msgid ""
2050 "The arguments to CW<\\*(C`given\\*(C'> and CW<\\*(C`when\\*(C'> are in "
2051 "scalar context, and CW<\\*(C`given\\*(C'> assigns the CW<$_> variable its "
2052 "topic value."
2053 msgstr ""
2054
2055 #. type: Plain text
2056 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2057 #: opensuse-leap-16-1 opensuse-tumbleweed
2058 msgid ""
2059 "Exactly what the I<EXPR> argument to CW<\\*(C`when\\*(C'> does is hard to "
2060 "describe precisely, but in general, it tries to guess what you want done. "
2061 "Sometimes it is interpreted as CW<\\*(C`$_ ~~ >\\f(CIEXPRCW<\\*(C'>, and "
2062 "sometimes it is not. It also behaves differently when lexically enclosed by "
2063 "a CW<\\*(C`given\\*(C'> block than it does when dynamically enclosed by a "
2064 "CW<\\*(C`foreach\\*(C'> loop. The rules are far too difficult to understand "
2065 "to be described here. See \"Experimental Details on given and when\" later "
2066 "on."
2067 msgstr ""
2068
2069 #. type: Plain text
2070 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2071 #: opensuse-leap-16-1 opensuse-tumbleweed
2072 msgid ""
2073 "Due to an unfortunate bug in how CW<\\*(C`given\\*(C'> was implemented "
2074 "between Perl 5.10 and 5.16, under those implementations the version of "
2075 "CW<$_> governed by \\&CW<\\*(C`given\\*(C'> is merely a lexically scoped "
2076 "copy of the original, not a dynamically scoped alias to the original, as it "
2077 "would be if it were a \\&CW<\\*(C`foreach\\*(C'> or under both the original "
2078 "and the current Raku language specification. This bug was fixed in Perl "
2079 "5.18 (and lexicalized CW<$_> itself was removed in Perl 5.24)."
2080 msgstr ""
2081
2082 #. type: Plain text
2083 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2084 #: opensuse-leap-16-1 opensuse-tumbleweed
2085 msgid ""
2086 "If your code still needs to run on older versions, stick to "
2087 "CW<\\*(C`foreach\\*(C'> for your topicalizer and you will be less unhappy."
2088 msgstr ""
2089
2090 #. type: IX
2091 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2092 #: opensuse-leap-16-1 opensuse-tumbleweed
2093 #, no-wrap
2094 msgid "Goto"
2095 msgstr ""
2096
2097 #. type: IX
2098 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2099 #: opensuse-leap-16-1 opensuse-tumbleweed
2100 #, no-wrap
2101 msgid "goto"
2102 msgstr ""
2103
2104 #. type: Plain text
2105 #: debian-trixie debian-unstable
2106 msgid ""
2107 "Although not for the faint of heart, Perl does support a "
2108 "CW<\\*(C`goto\\*(C'> statement. There are three forms: CW<\\*(C`goto\\*(C'>-"
2109 "LABEL, CW<\\*(C`goto\\*(C'>-EXPR, and \\&CW<\\*(C`goto\\*(C'>-&NAME. A "
2110 "loop's LABEL is not actually a valid target for a CW<\\*(C`goto\\*(C'>; it's "
2111 "just the name of the loop."
2112 msgstr ""
2113
2114 #. type: Plain text
2115 #: debian-trixie debian-unstable
2116 msgid ""
2117 "The CW<\\*(C`goto\\*(C'>-LABEL form finds the statement labeled with LABEL "
2118 "and resumes execution there. It may not be used to go into any construct "
2119 "that requires initialization, such as a subroutine or a "
2120 "CW<\\*(C`foreach\\*(C'> loop. It also can't be used to go into a construct "
2121 "that is optimized away. It can be used to go almost anywhere else within "
2122 "the dynamic scope, including out of subroutines, but it's usually better to "
2123 "use some other construct such as CW<\\*(C`last\\*(C'> or "
2124 "CW<\\*(C`die\\*(C'>. The author of Perl has never felt the need to use this "
2125 "form of CW<\\*(C`goto\\*(C'> (in Perl, that is--C is another matter)."
2126 msgstr ""
2127
2128 #. type: Plain text
2129 #: debian-trixie debian-unstable
2130 msgid ""
2131 "The CW<\\*(C`goto\\*(C'>-EXPR form expects a label name, whose scope will be "
2132 "resolved dynamically. This allows for computed CW<\\*(C`goto\\*(C'>s per "
2133 "FORTRAN, but isn't necessarily recommended if you're optimizing for "
2134 "maintainability:"
2135 msgstr ""
2136
2137 #. type: Plain text
2138 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2139 #: opensuse-leap-16-1 opensuse-tumbleweed
2140 #, no-wrap
2141 msgid "\\& goto((\"FOO\", \"BAR\", \"GLARCH\")[$i]);\n"
2142 msgstr ""
2143
2144 #. type: Plain text
2145 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2146 #: opensuse-leap-16-1 opensuse-tumbleweed
2147 msgid ""
2148 "The CW<\\*(C`goto\\*(C'>-&NAME form is highly magical, and substitutes a "
2149 "call to the named subroutine for the currently running subroutine. This is "
2150 "used by \\&CW<AUTOLOAD()> subroutines that wish to load another subroutine "
2151 "and then pretend that the other subroutine had been called in the first "
2152 "place (except that any modifications to CW<@_> in the current subroutine are "
2153 "propagated to the other subroutine.) After the CW<\\*(C`goto\\*(C'>, not "
2154 "even CW<caller()> will be able to tell that this routine was called first."
2155 msgstr ""
2156
2157 #. type: Plain text
2158 #: debian-trixie debian-unstable
2159 msgid ""
2160 "In almost all cases like this, it's usually a far, far better idea to use "
2161 "the structured control flow mechanisms of CW<\\*(C`next\\*(C'>, "
2162 "CW<\\*(C`last\\*(C'>, or CW<\\*(C`redo\\*(C'> instead of resorting to a "
2163 "CW<\\*(C`goto\\*(C'>. For certain applications, the catch and throw pair of "
2164 "\\&CW<\\*(C`eval{}\\*(C'> and B<die()> for exception processing can also be "
2165 "a prudent approach."
2166 msgstr ""
2167
2168 #. type: IX
2169 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2170 #: opensuse-leap-16-1 opensuse-tumbleweed
2171 #, no-wrap
2172 msgid "The Ellipsis Statement"
2173 msgstr ""
2174
2175 #. type: IX
2176 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2177 #: opensuse-leap-16-1 opensuse-tumbleweed
2178 #, no-wrap
2179 msgid "... ... statement ellipsis operator elliptical statement unimplemented statement unimplemented operator yada-yada yada-yada operator ... operator whatever operator triple-dot operator"
2180 msgstr ""
2181
2182 #. type: Plain text
2183 #: debian-trixie debian-unstable
2184 msgid ""
2185 "Beginning in Perl 5.12, Perl accepts an ellipsis, \"CW<\\*(C`...\\*(C'>\", "
2186 "as a placeholder for code that you haven't implemented yet. When Perl 5.12 "
2187 "or later encounters an ellipsis statement, it parses this without error, but "
2188 "if and when you should actually try to execute it, Perl throws an exception "
2189 "with the text CW<\\*(C`Unimplemented\\*(C'>:"
2190 msgstr ""
2191
2192 #. type: Plain text
2193 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2194 #: opensuse-leap-16-1 opensuse-tumbleweed
2195 #, no-wrap
2196 msgid ""
2197 "\\& use v5.12;\n"
2198 "\\& sub unimplemented { ... }\n"
2199 "\\& eval { unimplemented() };\n"
2200 "\\& if ($@ =~ /^Unimplemented at /) {\n"
2201 "\\& say \"I found an ellipsis!\";\n"
2202 "\\& }\n"
2203 msgstr ""
2204
2205 #. type: Plain text
2206 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2207 #: opensuse-leap-16-1 opensuse-tumbleweed
2208 msgid ""
2209 "You can only use the elliptical statement to stand in for a complete "
2210 "statement. Syntactically, \"CW<\\*(C`...;\\*(C'>\" is a complete statement, "
2211 "but, as with other kinds of semicolon-terminated statement, the semicolon "
2212 "may be omitted if \"CW<\\*(C`...\\*(C'>\" appears immediately before a "
2213 "closing brace. These examples show how the ellipsis works:"
2214 msgstr ""
2215
2216 #. type: Plain text
2217 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2218 #: opensuse-leap-16-1 opensuse-tumbleweed
2219 #, no-wrap
2220 msgid ""
2221 "\\& use v5.12;\n"
2222 "\\& { ... }\n"
2223 "\\& sub foo { ... }\n"
2224 "\\& ...;\n"
2225 "\\& eval { ... };\n"
2226 "\\& sub somemeth {\n"
2227 "\\& my $self = shift;\n"
2228 "\\& ...;\n"
2229 "\\& }\n"
2230 "\\& $x = do {\n"
2231 "\\& my $n;\n"
2232 "\\& ...;\n"
2233 "\\& say \"Hurrah!\";\n"
2234 "\\& $n;\n"
2235 "\\& };\n"
2236 msgstr ""
2237
2238 #. type: Plain text
2239 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2240 #: opensuse-leap-16-1 opensuse-tumbleweed
2241 msgid ""
2242 "The elliptical statement cannot stand in for an expression that is part of a "
2243 "larger statement. These examples of attempts to use an ellipsis are syntax "
2244 "errors:"
2245 msgstr ""
2246
2247 #. type: Plain text
2248 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2249 #: opensuse-leap-16-1 opensuse-tumbleweed
2250 #, no-wrap
2251 msgid ""
2252 "\\& use v5.12;\n"
2253 "\\&\n"
2254 "\\& print ...;\n"
2255 "\\& open(my $fh, \"E<gt>\", \"/dev/passwd\") or ...;\n"
2256 "\\& if ($condition && ... ) { say \"Howdy\" };\n"
2257 "\\& ... if $x E<gt> $y;\n"
2258 "\\& say \"Cromulent\" if ...;\n"
2259 "\\& $flub = 5 + ...;\n"
2260 msgstr ""
2261
2262 #. type: Plain text
2263 #: debian-trixie debian-unstable
2264 msgid ""
2265 "There are some cases where Perl can't immediately tell the difference "
2266 "between an expression and a statement. For instance, the syntax for a block "
2267 "and an anonymous hash reference constructor look the same unless there's "
2268 "something in the braces to give Perl a hint. The ellipsis is a syntax error "
2269 "if Perl doesn't guess that the CW<\\*(C`{ ... }\\*(C'> is a block. Inside "
2270 "your block, you can use a CW<\\*(C`;\\*(C'> before the ellipsis to denote "
2271 "that the \\&CW<\\*(C`{ ... }\\*(C'> is a block and not a hash reference "
2272 "constructor."
2273 msgstr ""
2274
2275 #. type: Plain text
2276 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2277 #: opensuse-leap-16-1 opensuse-tumbleweed
2278 msgid ""
2279 "Note: Some folks colloquially refer to this bit of punctuation as a \"yada-"
2280 "yada\" or \"triple-dot\", but its true name is actually an ellipsis."
2281 msgstr ""
2282
2283 #. type: IX
2284 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2285 #: opensuse-leap-16-1 opensuse-tumbleweed
2286 #, no-wrap
2287 msgid "PODs: Embedded Documentation"
2288 msgstr ""
2289
2290 #. type: IX
2291 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2292 #: opensuse-leap-16-1 opensuse-tumbleweed
2293 #, no-wrap
2294 msgid "POD documentation"
2295 msgstr ""
2296
2297 #. type: Plain text
2298 #: debian-trixie debian-unstable
2299 msgid ""
2300 "Perl has a mechanism for intermixing documentation with source code. While "
2301 "it's expecting the beginning of a new statement, if the compiler encounters "
2302 "a line that begins with an equal sign and a word, like this"
2303 msgstr ""
2304
2305 #. type: Plain text
2306 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2307 #: opensuse-leap-16-1 opensuse-tumbleweed
2308 #, no-wrap
2309 msgid "\\& =head1 Here There Be Pods!\n"
2310 msgstr ""
2311
2312 #. type: Plain text
2313 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2314 #: opensuse-leap-16-1 opensuse-tumbleweed
2315 msgid ""
2316 "Then that text and all remaining text up through and including a line "
2317 "beginning with CW<\\*(C`=cut\\*(C'> will be ignored. The format of the "
2318 "intervening text is described in perlpod."
2319 msgstr ""
2320
2321 #. type: Plain text
2322 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2323 #: opensuse-leap-16-1 opensuse-tumbleweed
2324 msgid ""
2325 "This allows you to intermix your source code and your documentation text "
2326 "freely, as in"
2327 msgstr ""
2328
2329 #. type: Plain text
2330 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2331 #: opensuse-leap-16-1 opensuse-tumbleweed
2332 #, no-wrap
2333 msgid ""
2334 "\\& =item snazzle($)\n"
2335 "\\&\n"
2336 "\\& The snazzle() function will behave in the most spectacular\n"
2337 "\\& form that you can possibly imagine, not even excepting\n"
2338 "\\& cybernetic pyrotechnics.\n"
2339 "\\&\n"
2340 "\\& =cut back to the compiler, nuff of this pod stuff!\n"
2341 "\\&\n"
2342 "\\& sub snazzle($) {\n"
2343 "\\& my $thingie = shift;\n"
2344 "\\& .........\n"
2345 "\\& }\n"
2346 msgstr ""
2347
2348 #. type: Plain text
2349 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2350 #: opensuse-leap-16-1 opensuse-tumbleweed
2351 msgid ""
2352 "Note that pod translators should look at only paragraphs beginning with a "
2353 "pod directive (it makes parsing easier), whereas the compiler actually knows "
2354 "to look for pod escapes even in the middle of a paragraph. This means that "
2355 "the following secret stuff will be ignored by both the compiler and the "
2356 "translators."
2357 msgstr ""
2358
2359 #. type: Plain text
2360 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2361 #: opensuse-leap-16-1 opensuse-tumbleweed
2362 #, no-wrap
2363 msgid ""
2364 "\\& $x=3;\n"
2365 "\\& =secret stuff\n"
2366 "\\& warn \"Neither POD nor CODE!?\"\n"
2367 "\\& =cut back\n"
2368 "\\& print \"got $x\\en\";\n"
2369 msgstr ""
2370
2371 #. type: Plain text
2372 #: debian-trixie debian-unstable
2373 msgid ""
2374 "You probably shouldn't rely upon the CW<warn()> being podded out forever. "
2375 "Not all pod translators are well-behaved in this regard, and perhaps the "
2376 "compiler will become pickier."
2377 msgstr ""
2378
2379 #. type: Plain text
2380 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2381 #: opensuse-leap-16-1 opensuse-tumbleweed
2382 msgid ""
2383 "One may also use pod directives to quickly comment out a section of code."
2384 msgstr ""
2385
2386 #. type: IX
2387 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2388 #: opensuse-leap-16-1 opensuse-tumbleweed
2389 #, no-wrap
2390 msgid "Plain Old Comments (Not!)"
2391 msgstr ""
2392
2393 #. type: IX
2394 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2395 #: opensuse-leap-16-1 opensuse-tumbleweed
2396 #, no-wrap
2397 msgid "comment line # preprocessor eval"
2398 msgstr ""
2399
2400 #. type: Plain text
2401 #: debian-trixie debian-unstable
2402 msgid ""
2403 "Perl can process line directives, much like the C preprocessor. Using this, "
2404 "one can control Perl's idea of filenames and line numbers in error or "
2405 "warning messages (especially for strings that are processed with "
2406 "CW<eval()>). The syntax for this mechanism is almost the same as for most C "
2407 "preprocessors: it matches the regular expression"
2408 msgstr ""
2409
2410 #. type: Plain text
2411 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2412 #: opensuse-leap-16-1 opensuse-tumbleweed
2413 #, no-wrap
2414 msgid ""
2415 "\\& # example: \\*(Aq# line 42 \"new_filename.plx\"\\*(Aq\n"
2416 "\\& /^\\e# \\es*\n"
2417 "\\& line \\es+ (\\ed+) \\es*\n"
2418 "\\& (?:\\es(\"?)([^\"]+)\\eg2)? \\es*\n"
2419 "\\& $/x\n"
2420 msgstr ""
2421
2422 #. type: Plain text
2423 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2424 #: opensuse-leap-16-1 opensuse-tumbleweed
2425 msgid ""
2426 "with CW<$1> being the line number for the next line, and CW<$3> being the "
2427 "optional filename (specified with or without quotes). Note that no "
2428 "whitespace may precede the CW<\\*(C`#\\*(C'>, unlike modern C preprocessors."
2429 msgstr ""
2430
2431 #. type: Plain text
2432 #: debian-trixie debian-unstable
2433 msgid ""
2434 "There is a fairly obvious gotcha included with the line directive: Debuggers "
2435 "and profilers will only show the last source line to appear at a particular "
2436 "line number in a given file. Care should be taken not to cause line number "
2437 "collisions in code you'd like to debug later."
2438 msgstr ""
2439
2440 #. type: Plain text
2441 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2442 #: opensuse-leap-16-1 opensuse-tumbleweed
2443 msgid ""
2444 "Here are some examples that you should be able to type into your command "
2445 "shell:"
2446 msgstr ""
2447
2448 #. type: Plain text
2449 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2450 #: opensuse-leap-16-1 opensuse-tumbleweed
2451 #, no-wrap
2452 msgid ""
2453 "\\& % perl\n"
2454 "\\& # line 200 \"bzzzt\"\n"
2455 "\\& # the \\*(Aq#\\*(Aq on the previous line must be the first char on line\n"
2456 "\\& die \\*(Aqfoo\\*(Aq;\n"
2457 "\\& _\\|_END_\\|_\n"
2458 "\\& foo at bzzzt line 201.\n"
2459 "\\&\n"
2460 "\\& % perl\n"
2461 "\\& # line 200 \"bzzzt\"\n"
2462 "\\& eval qq[\\en#line 2001 \"\"\\endie \\*(Aqfoo\\*(Aq]; print $@;\n"
2463 "\\& _\\|_END_\\|_\n"
2464 "\\& foo at - line 2001.\n"
2465 "\\&\n"
2466 "\\& % perl\n"
2467 "\\& eval qq[\\en#line 200 \"foo bar\"\\endie \\*(Aqfoo\\*(Aq]; print $@;\n"
2468 "\\& _\\|_END_\\|_\n"
2469 "\\& foo at foo bar line 200.\n"
2470 "\\&\n"
2471 "\\& % perl\n"
2472 "\\& # line 345 \"goop\"\n"
2473 "\\& eval \"\\en#line \" . _\\|_LINE_\\|_ . \\*(Aq \"\\*(Aq . _\\|_FILE_\\|_ .\"\\e\"\\endie \\*(Aqfoo\\*(Aq\";\n"
2474 "\\& print $@;\n"
2475 "\\& _\\|_END_\\|_\n"
2476 "\\& foo at goop line 345.\n"
2477 msgstr ""
2478
2479 #. type: IX
2480 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2481 #: opensuse-leap-16-1 opensuse-tumbleweed
2482 #, no-wrap
2483 msgid "Experimental Details on given and when"
2484 msgstr ""
2485
2486 #. type: Plain text
2487 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2488 #: opensuse-leap-16-1 opensuse-tumbleweed
2489 msgid ""
2490 "As previously mentioned, the \"switch\" feature is considered highly "
2491 "experimental (it is also scheduled to be removed in perl 5.42.0); it is "
2492 "subject to change with little notice. In particular, "
2493 "\\&CW<\\*(C`when\\*(C'> has tricky behaviours that are expected to change to "
2494 "become less tricky in the future. Do not rely upon its current "
2495 "(mis)implementation. Before Perl 5.18, CW<\\*(C`given\\*(C'> also had "
2496 "tricky behaviours that you should still beware of if your code must run on "
2497 "older versions of Perl."
2498 msgstr ""
2499
2500 #. type: Plain text
2501 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2502 #: opensuse-leap-16-1 opensuse-tumbleweed
2503 msgid "Here is a longer example of CW<\\*(C`given\\*(C'>:"
2504 msgstr ""
2505
2506 #. type: Plain text
2507 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2508 #: opensuse-leap-16-1 opensuse-tumbleweed
2509 #, no-wrap
2510 msgid ""
2511 "\\& use feature \":5.10\";\n"
2512 "\\& given ($foo) {\n"
2513 "\\& when (undef) {\n"
2514 "\\& say \\*(Aq$foo is undefined\\*(Aq;\n"
2515 "\\& }\n"
2516 "\\& when (\"foo\") {\n"
2517 "\\& say \\*(Aq$foo is the string \"foo\"\\*(Aq;\n"
2518 "\\& }\n"
2519 "\\& when ([1,3,5,7,9]) {\n"
2520 "\\& say \\*(Aq$foo is an odd digit\\*(Aq;\n"
2521 "\\& continue; # Fall through\n"
2522 "\\& }\n"
2523 "\\& when ($_ E<lt> 100) {\n"
2524 "\\& say \\*(Aq$foo is numerically less than 100\\*(Aq;\n"
2525 "\\& }\n"
2526 "\\& when (\\e&complicated_check) {\n"
2527 "\\& say \\*(Aqa complicated check for $foo is true\\*(Aq;\n"
2528 "\\& }\n"
2529 "\\& default {\n"
2530 "\\& die q(I don\\*(Aqt know what to do with $foo);\n"
2531 "\\& }\n"
2532 "\\& }\n"
2533 msgstr ""
2534
2535 #. type: Plain text
2536 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2537 #: opensuse-leap-16-1 opensuse-tumbleweed
2538 msgid ""
2539 "Before Perl 5.18, CW<given(EXPR)> assigned the value of I<EXPR> to merely a "
2540 "lexically scoped \\f(BIcopy\\fR (!) of CW<$_>, not a dynamically scoped "
2541 "alias the way CW<\\*(C`foreach\\*(C'> does. That made it similar to"
2542 msgstr ""
2543
2544 #. type: Plain text
2545 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2546 #: opensuse-leap-16-1 opensuse-tumbleweed
2547 #, no-wrap
2548 msgid "\\& do { my $_ = EXPR; ... }\n"
2549 msgstr ""
2550
2551 #. type: Plain text
2552 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2553 #: opensuse-leap-16-1 opensuse-tumbleweed
2554 msgid ""
2555 "except that the block was automatically broken out of by a successful "
2556 "\\&CW<\\*(C`when\\*(C'> or an explicit CW<\\*(C`break\\*(C'>. Because it "
2557 "was only a copy, and because it was only lexically scoped, not dynamically "
2558 "scoped, you could not do the things with it that you are used to in a "
2559 "CW<\\*(C`foreach\\*(C'> loop. In particular, it did not work for arbitrary "
2560 "function calls if those functions might try to access CW<$_>. Best stick to "
2561 "CW<\\*(C`foreach\\*(C'> for that."
2562 msgstr ""
2563
2564 #. type: Plain text
2565 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2566 #: opensuse-leap-16-1 opensuse-tumbleweed
2567 msgid ""
2568 "Most of the power comes from the implicit smartmatching that can sometimes "
2569 "apply. Most of the time, CW<when(EXPR)> is treated as an implicit "
2570 "smartmatch of CW<$_>, that is, CW<\\*(C`$_ ~~ EXPR\\*(C'>. (See "
2571 "\"Smartmatch Operator\" in perlop for more information on smartmatching.) "
2572 "But when I<EXPR> is one of the 10 exceptional cases (or things like them) "
2573 "listed below, it is used directly as a boolean."
2574 msgstr ""
2575
2576 #. type: IX
2577 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2578 #: opensuse-leap-16-1 opensuse-tumbleweed
2579 #, no-wrap
2580 msgid "1."
2581 msgstr ""
2582
2583 #. type: IX
2584 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2585 #: opensuse-leap-16-1 opensuse-tumbleweed
2586 #, no-wrap
2587 msgid "Item"
2588 msgstr ""
2589
2590 #. type: Plain text
2591 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2592 #: opensuse-leap-16-1 opensuse-tumbleweed
2593 msgid "A user-defined subroutine call or a method invocation."
2594 msgstr ""
2595
2596 #. type: IX
2597 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2598 #: opensuse-leap-16-1 opensuse-tumbleweed
2599 #, no-wrap
2600 msgid "2."
2601 msgstr ""
2602
2603 #. type: Plain text
2604 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2605 #: opensuse-leap-16-1 opensuse-tumbleweed
2606 msgid ""
2607 "A regular expression match in the form of CW<\\*(C`/REGEX/\\*(C'>, "
2608 "CW<\\*(C`$foo =~ /REGEX/\\*(C'>, or CW<\\*(C`$foo =~ EXPR\\*(C'>. Also, a "
2609 "negated regular expression match in the form CW<\\*(C`!/REGEX/\\*(C'>, "
2610 "CW<\\*(C`$foo !~ /REGEX/\\*(C'>, or CW<\\*(C`$foo !~ EXPR\\*(C'>."
2611 msgstr ""
2612
2613 #. type: IX
2614 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2615 #: opensuse-leap-16-1 opensuse-tumbleweed
2616 #, no-wrap
2617 msgid "3."
2618 msgstr ""
2619
2620 #. type: Plain text
2621 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2622 #: opensuse-leap-16-1 opensuse-tumbleweed
2623 msgid ""
2624 "A smart match that uses an explicit CW<\\*(C`~~\\*(C'> operator, such as "
2625 "CW<\\*(C`EXPR ~~ EXPR\\*(C'>."
2626 msgstr ""
2627
2628 #. type: Plain text
2629 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2630 #: opensuse-leap-16-1 opensuse-tumbleweed
2631 msgid ""
2632 "\\&B<NOTE:> You will often have to use CW<\\*(C`$c ~~ $_\\*(C'> because the "
2633 "default case uses CW<\\*(C`$_ ~~ $c\\*(C'> , which is frequently the "
2634 "opposite of what you want."
2635 msgstr ""
2636
2637 #. type: IX
2638 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2639 #: opensuse-leap-16-1 opensuse-tumbleweed
2640 #, no-wrap
2641 msgid "4."
2642 msgstr ""
2643
2644 #. type: Plain text
2645 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2646 #: opensuse-leap-16-1 opensuse-tumbleweed
2647 msgid ""
2648 "A boolean comparison operator such as CW<\\*(C`$_ E<lt> 10\\*(C'> or "
2649 "CW<\\*(C`$x eq \"abc\"\\*(C'>. The relational operators that this applies "
2650 "to are the six numeric comparisons (CW<\\*(C`E<lt>\\*(C'>, "
2651 "CW<\\*(C`E<gt>\\*(C'>, CW<\\*(C`E<lt>=\\*(C'>, CW<\\*(C`E<gt>=\\*(C'>, "
2652 "CW<\\*(C`==\\*(C'>, and CW<\\*(C`!=\\*(C'>), and the six string comparisons "
2653 "(CW<\\*(C`lt\\*(C'>, CW<\\*(C`gt\\*(C'>, CW<\\*(C`le\\*(C'>, "
2654 "CW<\\*(C`ge\\*(C'>, CW<\\*(C`eq\\*(C'>, and CW<\\*(C`ne\\*(C'>)."
2655 msgstr ""
2656
2657 #. type: IX
2658 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2659 #: opensuse-leap-16-1 opensuse-tumbleweed
2660 #, no-wrap
2661 msgid "5."
2662 msgstr ""
2663
2664 #. type: Plain text
2665 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2666 #: opensuse-leap-16-1 opensuse-tumbleweed
2667 msgid ""
2668 "At least the three builtin functions CW<defined(...)>, CW<exists(...)>, and "
2669 "\\&CW<eof(...)>. We might someday add more of these later if we think of "
2670 "them."
2671 msgstr ""
2672
2673 #. type: IX
2674 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2675 #: opensuse-leap-16-1 opensuse-tumbleweed
2676 #, no-wrap
2677 msgid "6."
2678 msgstr ""
2679
2680 #. type: Plain text
2681 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2682 #: opensuse-leap-16-1 opensuse-tumbleweed
2683 msgid ""
2684 "A negated expression, whether CW<\\*(C`!(EXPR)\\*(C'> or CW<not(EXPR)>, or a "
2685 "logical exclusive-or, CW<\\*(C`(EXPR1) xor (EXPR2)\\*(C'>. The bitwise "
2686 "versions (CW<\\*(C`~\\*(C'> and CW<\\*(C`^\\*(C'>) are not included."
2687 msgstr ""
2688
2689 #. type: IX
2690 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2691 #: opensuse-leap-16-1 opensuse-tumbleweed
2692 #, no-wrap
2693 msgid "7."
2694 msgstr ""
2695
2696 #. type: Plain text
2697 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2698 #: opensuse-leap-16-1 opensuse-tumbleweed
2699 msgid ""
2700 "A filetest operator, with exactly 4 exceptions: CW<\\*(C`-s\\*(C'>, "
2701 "CW<\\*(C`-M\\*(C'>, CW<\\*(C`-A\\*(C'>, and \\&CW<\\*(C`-C\\*(C'>, as these "
2702 "return numerical values, not boolean ones. The CW<\\*(C`-z\\*(C'> filetest "
2703 "operator is not included in the exception list."
2704 msgstr ""
2705
2706 #. type: IX
2707 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2708 #: opensuse-leap-16-1 opensuse-tumbleweed
2709 #, no-wrap
2710 msgid "8."
2711 msgstr ""
2712
2713 #. type: Plain text
2714 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2715 #: opensuse-leap-16-1 opensuse-tumbleweed
2716 msgid ""
2717 "The CW<\\*(C`..\\*(C'> and CW<\\*(C`...\\*(C'> flip-flop operators. Note "
2718 "that the CW<\\*(C`...\\*(C'> flip-flop operator is completely different from "
2719 "the CW<\\*(C`...\\*(C'> elliptical statement just described."
2720 msgstr ""
2721
2722 #. type: Plain text
2723 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2724 #: opensuse-leap-16-1 opensuse-tumbleweed
2725 msgid ""
2726 "In those 8 cases above, the value of EXPR is used directly as a boolean, so "
2727 "no smartmatching is done. You may think of CW<\\*(C`when\\*(C'> as a "
2728 "smartsmartmatch."
2729 msgstr ""
2730
2731 #. type: Plain text
2732 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2733 #: opensuse-leap-16-1 opensuse-tumbleweed
2734 msgid ""
2735 "Furthermore, Perl inspects the operands of logical operators to decide "
2736 "whether to use smartmatching for each one by applying the above test to the "
2737 "operands:"
2738 msgstr ""
2739
2740 #. type: IX
2741 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2742 #: opensuse-leap-16-1 opensuse-tumbleweed
2743 #, no-wrap
2744 msgid "9."
2745 msgstr ""
2746
2747 #. type: Plain text
2748 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2749 #: opensuse-leap-16-1 opensuse-tumbleweed
2750 msgid ""
2751 "If EXPR is CW<\\*(C`EXPR1 && EXPR2\\*(C'> or CW<\\*(C`EXPR1 and "
2752 "EXPR2\\*(C'>, the test is applied \\&I<recursively> to both EXPR1 and "
2753 "EXPR2. Only if I<both> operands also pass the test, I<recursively>, will "
2754 "the expression be treated as boolean. Otherwise, smartmatching is used."
2755 msgstr ""
2756
2757 #. type: IX
2758 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2759 #: opensuse-leap-16-1 opensuse-tumbleweed
2760 #, no-wrap
2761 msgid "10."
2762 msgstr ""
2763
2764 #. type: Plain text
2765 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2766 #: opensuse-leap-16-1 opensuse-tumbleweed
2767 msgid ""
2768 "If EXPR is CW<\\*(C`EXPR1 || EXPR2\\*(C'>, CW<\\*(C`EXPR1 // EXPR2\\*(C'>, "
2769 "or CW<\\*(C`EXPR1 or EXPR2\\*(C'>, the test is applied I<recursively> to "
2770 "EXPR1 only (which might itself be a higher-precedence AND operator, for "
2771 "example, and thus subject to the previous rule), not to EXPR2. If EXPR1 is "
2772 "to use smartmatching, then EXPR2 also does so, no matter what EXPR2 "
2773 "contains. But if EXPR2 does not get to use smartmatching, then the second "
2774 "argument will not be either. This is quite different from the "
2775 "CW<\\*(C`&&\\*(C'> case just described, so be careful."
2776 msgstr ""
2777
2778 #. type: Plain text
2779 #: debian-trixie debian-unstable
2780 msgid ""
2781 "These rules are complicated, but the goal is for them to do what you want "
2782 "(even if you don't quite understand why they are doing it). For example:"
2783 msgstr ""
2784
2785 #. type: Plain text
2786 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2787 #: opensuse-leap-16-1 opensuse-tumbleweed
2788 #, no-wrap
2789 msgid "\\& when (/^\\ed+$/ && $_ E<lt> 75) { ... }\n"
2790 msgstr ""
2791
2792 #. type: Plain text
2793 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2794 #: opensuse-leap-16-1 opensuse-tumbleweed
2795 msgid ""
2796 "will be treated as a boolean match because the rules say both a regex match "
2797 "and an explicit test on CW<$_> will be treated as boolean."
2798 msgstr ""
2799
2800 #. type: Plain text
2801 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2802 #: opensuse-leap-16-1 opensuse-tumbleweed
2803 msgid "Also:"
2804 msgstr ""
2805
2806 #. type: Plain text
2807 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2808 #: opensuse-leap-16-1 opensuse-tumbleweed
2809 #, no-wrap
2810 msgid "\\& when ([qw(foo bar)] && /baz/) { ... }\n"
2811 msgstr ""
2812
2813 #. type: Plain text
2814 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2815 #: opensuse-leap-16-1 opensuse-tumbleweed
2816 msgid ""
2817 "will use smartmatching because only I<one> of the operands is a boolean: the "
2818 "other uses smartmatching, and that wins."
2819 msgstr ""
2820
2821 #. type: Plain text
2822 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2823 #: opensuse-leap-16-1 opensuse-tumbleweed
2824 msgid "Further:"
2825 msgstr ""
2826
2827 #. type: Plain text
2828 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2829 #: opensuse-leap-16-1 opensuse-tumbleweed
2830 #, no-wrap
2831 msgid "\\& when ([qw(foo bar)] || /^baz/) { ... }\n"
2832 msgstr ""
2833
2834 #. type: Plain text
2835 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2836 #: opensuse-leap-16-1 opensuse-tumbleweed
2837 msgid "will use smart matching (only the first operand is considered), whereas"
2838 msgstr ""
2839
2840 #. type: Plain text
2841 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2842 #: opensuse-leap-16-1 opensuse-tumbleweed
2843 #, no-wrap
2844 msgid "\\& when (/^baz/ || [qw(foo bar)]) { ... }\n"
2845 msgstr ""
2846
2847 #. type: Plain text
2848 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2849 #: opensuse-leap-16-1 opensuse-tumbleweed
2850 msgid ""
2851 "will test only the regex, which causes both operands to be treated as "
2852 "boolean. Watch out for this one, then, because an arrayref is always a true "
2853 "value, which makes it effectively redundant. Not a good idea."
2854 msgstr ""
2855
2856 #. type: Plain text
2857 #: debian-trixie debian-unstable
2858 msgid ""
2859 "Tautologous boolean operators are still going to be optimized away. Don't "
2860 "be tempted to write"
2861 msgstr ""
2862
2863 #. type: Plain text
2864 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2865 #: opensuse-leap-16-1 opensuse-tumbleweed
2866 #, no-wrap
2867 msgid "\\& when (\"foo\" or \"bar\") { ... }\n"
2868 msgstr ""
2869
2870 #. type: Plain text
2871 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2872 #: opensuse-leap-16-1 opensuse-tumbleweed
2873 msgid ""
2874 "This will optimize down to CW<\"foo\">, so CW<\"bar\"> will never be "
2875 "considered (even though the rules say to use a smartmatch on CW<\"foo\">). "
2876 "For an alternation like this, an array ref will work, because this will "
2877 "instigate smartmatching:"
2878 msgstr ""
2879
2880 #. type: Plain text
2881 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2882 #: opensuse-leap-16-1 opensuse-tumbleweed
2883 #, no-wrap
2884 msgid "\\& when ([qw(foo bar)] { ... }\n"
2885 msgstr ""
2886
2887 #. type: Plain text
2888 #: debian-trixie debian-unstable
2889 msgid ""
2890 "This is somewhat equivalent to the C-style switch statement's fallthrough "
2891 "functionality (not to be confused with I<Perl's> fallthrough functionality--"
2892 "see below), wherein the same block is used for several "
2893 "\\&CW<\\*(C`case\\*(C'> statements."
2894 msgstr ""
2895
2896 #. type: Plain text
2897 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2898 #: opensuse-leap-16-1 opensuse-tumbleweed
2899 msgid ""
2900 "Another useful shortcut is that, if you use a literal array or hash as the "
2901 "argument to CW<\\*(C`given\\*(C'>, it is turned into a reference. So "
2902 "CW<given(@foo)> is the same as CW<given(\\e@foo)>, for example."
2903 msgstr ""
2904
2905 #. type: Plain text
2906 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2907 #: opensuse-leap-16-1 opensuse-tumbleweed
2908 msgid ""
2909 "\\&CW<\\*(C`default\\*(C'> behaves exactly like CW<\\*(C`when(1 == "
2910 "1)\\*(C'>, which is to say that it always matches."
2911 msgstr ""
2912
2913 #. type: Plain text
2914 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2915 #: opensuse-leap-16-1 opensuse-tumbleweed
2916 msgid "I<Breaking out>"
2917 msgstr ""
2918
2919 #. type: IX
2920 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2921 #: opensuse-leap-16-1 opensuse-tumbleweed
2922 #, no-wrap
2923 msgid "Breaking out"
2924 msgstr ""
2925
2926 #. type: Plain text
2927 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2928 #: opensuse-leap-16-1 opensuse-tumbleweed
2929 msgid ""
2930 "You can use the CW<\\*(C`break\\*(C'> keyword to break out of the enclosing "
2931 "\\&CW<\\*(C`given\\*(C'> block. Every CW<\\*(C`when\\*(C'> block is "
2932 "implicitly ended with a CW<\\*(C`break\\*(C'>."
2933 msgstr ""
2934
2935 #. type: Plain text
2936 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2937 #: opensuse-leap-16-1 opensuse-tumbleweed
2938 msgid "I<Fall-through>"
2939 msgstr ""
2940
2941 #. type: IX
2942 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2943 #: opensuse-leap-16-1 opensuse-tumbleweed
2944 #, no-wrap
2945 msgid "Fall-through"
2946 msgstr ""
2947
2948 #. type: Plain text
2949 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2950 #: opensuse-leap-16-1 opensuse-tumbleweed
2951 msgid ""
2952 "You can use the CW<\\*(C`continue\\*(C'> keyword to fall through from one "
2953 "case to the next immediate CW<\\*(C`when\\*(C'> or CW<\\*(C`default\\*(C'>:"
2954 msgstr ""
2955
2956 #. type: Plain text
2957 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2958 #: opensuse-leap-16-1 opensuse-tumbleweed
2959 #, no-wrap
2960 msgid ""
2961 "\\& given($foo) {\n"
2962 "\\& when (/x/) { say \\*(Aq$foo contains an x\\*(Aq; continue }\n"
2963 "\\& when (/y/) { say \\*(Aq$foo contains a y\\*(Aq }\n"
2964 "\\& default { say \\*(Aq$foo does not contain a y\\*(Aq }\n"
2965 "\\& }\n"
2966 msgstr ""
2967
2968 #. type: Plain text
2969 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2970 #: opensuse-leap-16-1 opensuse-tumbleweed
2971 msgid "I<Return value>"
2972 msgstr ""
2973
2974 #. type: IX
2975 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2976 #: opensuse-leap-16-1 opensuse-tumbleweed
2977 #, no-wrap
2978 msgid "Return value"
2979 msgstr ""
2980
2981 #. type: Plain text
2982 #: debian-trixie debian-unstable
2983 msgid ""
2984 "When a CW<\\*(C`given\\*(C'> statement is also a valid expression (for "
2985 "example, when it's the last statement of a block), it evaluates to:"
2986 msgstr ""
2987
2988 #. type: IP
2989 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2990 #: opensuse-leap-16-1 opensuse-tumbleweed
2991 #, no-wrap
2992 msgid "\\(bu"
2993 msgstr ""
2994
2995 #. type: Plain text
2996 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
2997 #: opensuse-leap-16-1 opensuse-tumbleweed
2998 msgid ""
2999 "An empty list as soon as an explicit CW<\\*(C`break\\*(C'> is encountered."
3000 msgstr ""
3001
3002 #. type: Plain text
3003 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3004 #: opensuse-leap-16-1 opensuse-tumbleweed
3005 msgid ""
3006 "The value of the last evaluated expression of the successful "
3007 "\\&CW<\\*(C`when\\*(C'>/CW<\\*(C`default\\*(C'> clause, if there happens to "
3008 "be one."
3009 msgstr ""
3010
3011 #. type: Plain text
3012 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3013 #: opensuse-leap-16-1 opensuse-tumbleweed
3014 msgid ""
3015 "The value of the last evaluated expression of the CW<\\*(C`given\\*(C'> "
3016 "block if no condition is true."
3017 msgstr ""
3018
3019 #. type: Plain text
3020 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3021 #: opensuse-leap-16-1 opensuse-tumbleweed
3022 msgid ""
3023 "In both last cases, the last expression is evaluated in the context that was "
3024 "applied to the CW<\\*(C`given\\*(C'> block."
3025 msgstr ""
3026
3027 #. type: Plain text
3028 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3029 #: opensuse-leap-16-1 opensuse-tumbleweed
3030 msgid ""
3031 "Note that, unlike CW<\\*(C`if\\*(C'> and CW<\\*(C`unless\\*(C'>, failed "
3032 "CW<\\*(C`when\\*(C'> statements always evaluate to an empty list."
3033 msgstr ""
3034
3035 #. type: Plain text
3036 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3037 #: opensuse-leap-16-1 opensuse-tumbleweed
3038 #, no-wrap
3039 msgid ""
3040 "\\& my $price = do {\n"
3041 "\\& given ($item) {\n"
3042 "\\& when ([\"pear\", \"apple\"]) { 1 }\n"
3043 "\\& break when \"vote\"; # My vote cannot be bought\n"
3044 "\\& 1e10 when /Mona Lisa/;\n"
3045 "\\& \"unknown\";\n"
3046 "\\& }\n"
3047 "\\& };\n"
3048 msgstr ""
3049
3050 #. type: Plain text
3051 #: debian-trixie debian-unstable
3052 msgid ""
3053 "Currently, CW<\\*(C`given\\*(C'> blocks can't always be used as proper "
3054 "expressions. This may be addressed in a future version of Perl."
3055 msgstr ""
3056
3057 #. type: Plain text
3058 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3059 #: opensuse-leap-16-1 opensuse-tumbleweed
3060 msgid "I<Switching in a loop>"
3061 msgstr ""
3062
3063 #. type: IX
3064 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3065 #: opensuse-leap-16-1 opensuse-tumbleweed
3066 #, no-wrap
3067 msgid "Switching in a loop"
3068 msgstr ""
3069
3070 #. type: Plain text
3071 #: debian-trixie debian-unstable
3072 msgid ""
3073 "Instead of using CW<given()>, you can use a CW<foreach()> loop. For "
3074 "example, here's one way to count how many times a particular string occurs "
3075 "in an array:"
3076 msgstr ""
3077
3078 #. type: Plain text
3079 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3080 #: opensuse-leap-16-1 opensuse-tumbleweed
3081 #, no-wrap
3082 msgid ""
3083 "\\& use v5.10.1;\n"
3084 "\\& my $count = 0;\n"
3085 "\\& for (@array) {\n"
3086 "\\& when (\"foo\") { ++$count }\n"
3087 "\\& }\n"
3088 "\\& print \"\\e@array contains $count copies of \\*(Aqfoo\\*(Aq\\en\";\n"
3089 msgstr ""
3090
3091 #. type: Plain text
3092 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3093 #: opensuse-leap-16-1 opensuse-tumbleweed
3094 msgid "Or in a more recent version:"
3095 msgstr ""
3096
3097 #. type: Plain text
3098 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3099 #: opensuse-leap-16-1 opensuse-tumbleweed
3100 #, no-wrap
3101 msgid ""
3102 "\\& use v5.14;\n"
3103 "\\& my $count = 0;\n"
3104 "\\& for (@array) {\n"
3105 "\\& ++$count when \"foo\";\n"
3106 "\\& }\n"
3107 "\\& print \"\\e@array contains $count copies of \\*(Aqfoo\\*(Aq\\en\";\n"
3108 msgstr ""
3109
3110 #. type: Plain text
3111 #: debian-trixie debian-unstable
3112 msgid ""
3113 "At the end of all CW<\\*(C`when\\*(C'> blocks, there is an implicit "
3114 "CW<\\*(C`next\\*(C'>. You can override that with an explicit "
3115 "CW<\\*(C`last\\*(C'> if you're interested in only the first match alone."
3116 msgstr ""
3117
3118 #. type: Plain text
3119 #: debian-trixie debian-unstable
3120 msgid ""
3121 "This doesn't work if you explicitly specify a loop variable, as in "
3122 "CW<\\*(C`for $item (@array)\\*(C'>. You have to use the default variable "
3123 "CW<$_>."
3124 msgstr ""
3125
3126 #. type: Plain text
3127 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3128 #: opensuse-leap-16-1 opensuse-tumbleweed
3129 msgid "I<Differences from Raku>"
3130 msgstr ""
3131
3132 #. type: IX
3133 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3134 #: opensuse-leap-16-1 opensuse-tumbleweed
3135 #, no-wrap
3136 msgid "Differences from Raku"
3137 msgstr ""
3138
3139 #. type: Plain text
3140 #: debian-trixie debian-unstable
3141 msgid ""
3142 "The Perl 5 smartmatch and CW<\\*(C`given\\*(C'>/CW<\\*(C`when\\*(C'> "
3143 "constructs are not compatible with their Raku analogues. The most visible "
3144 "difference and least important difference is that, in Perl 5, parentheses "
3145 "are required around the argument to CW<given()> and CW<when()> (except when "
3146 "this last one is used as a statement modifier). Parentheses in Raku are "
3147 "always optional in a control construct such as CW<if()>, CW<while()>, or "
3148 "CW<when()>; they can't be made optional in Perl 5 without a great deal of "
3149 "potential confusion, because Perl 5 would parse the expression"
3150 msgstr ""
3151
3152 #. type: Plain text
3153 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3154 #: opensuse-leap-16-1 opensuse-tumbleweed
3155 #, no-wrap
3156 msgid ""
3157 "\\& given $foo {\n"
3158 "\\& ...\n"
3159 "\\& }\n"
3160 msgstr ""
3161
3162 #. type: Plain text
3163 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3164 #: opensuse-leap-16-1 opensuse-tumbleweed
3165 msgid ""
3166 "as though the argument to CW<\\*(C`given\\*(C'> were an element of the hash "
3167 "\\&CW<%foo>, interpreting the braces as hash-element syntax."
3168 msgstr ""
3169
3170 #. type: Plain text
3171 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3172 #: opensuse-leap-16-1 opensuse-tumbleweed
3173 msgid ""
3174 "However, there are many, many other differences. For example, this works in "
3175 "Perl 5:"
3176 msgstr ""
3177
3178 #. type: Plain text
3179 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3180 #: opensuse-leap-16-1 opensuse-tumbleweed
3181 #, no-wrap
3182 msgid ""
3183 "\\& use v5.12;\n"
3184 "\\& my @primary = (\"red\", \"blue\", \"green\");\n"
3185 "\\&\n"
3186 "\\& if (@primary ~~ \"red\") {\n"
3187 "\\& say \"primary smartmatches red\";\n"
3188 "\\& }\n"
3189 "\\&\n"
3190 "\\& if (\"red\" ~~ @primary) {\n"
3191 "\\& say \"red smartmatches primary\";\n"
3192 "\\& }\n"
3193 "\\&\n"
3194 "\\& say \"that\\*(Aqs all, folks!\";\n"
3195 msgstr ""
3196
3197 #. type: Plain text
3198 #: debian-trixie debian-unstable
3199 msgid ""
3200 "But it doesn't work at all in Raku. Instead, you should use the "
3201 "(parallelizable) CW<\\*(C`any\\*(C'> operator:"
3202 msgstr ""
3203
3204 #. type: Plain text
3205 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3206 #: opensuse-leap-16-1 opensuse-tumbleweed
3207 #, no-wrap
3208 msgid ""
3209 "\\& if any(@primary) eq \"red\" {\n"
3210 "\\& say \"primary smartmatches red\";\n"
3211 "\\& }\n"
3212 "\\&\n"
3213 "\\& if \"red\" eq any(@primary) {\n"
3214 "\\& say \"red smartmatches primary\";\n"
3215 "\\& }\n"
3216 msgstr ""
3217
3218 #. type: Plain text
3219 #: debian-trixie debian-unstable
3220 msgid ""
3221 "The table of smartmatches in \"Smartmatch Operator\" in perlop is not "
3222 "identical to that proposed by the Raku specification, mainly due to "
3223 "differences between Raku's and Perl 5's data models, but also because the "
3224 "Raku spec has changed since Perl 5 rushed into early adoption."
3225 msgstr ""
3226
3227 #. type: Plain text
3228 #: debian-trixie debian-unstable fedora-44 fedora-rawhide mageia-cauldron
3229 #: opensuse-leap-16-1 opensuse-tumbleweed
3230 msgid ""
3231 "In Raku, CW<when()> will always do an implicit smartmatch with its argument, "
3232 "while in Perl 5 it is convenient (albeit potentially confusing) to suppress "
3233 "this implicit smartmatch in various rather loosely-defined situations, as "
3234 "roughly outlined above. (The difference is largely because Perl 5 does not "
3235 "have, even internally, a boolean type.)"
3236 msgstr ""
3237
3238 #. type: TH
3239 #: debian-unstable
3240 #, no-wrap
3241 msgid "2025-11-16"
3242 msgstr ""
3243
3244 #. type: TH
3245 #: fedora-44 opensuse-leap-16-1 opensuse-tumbleweed
3246 #, no-wrap
3247 msgid "2026-03-09"
3248 msgstr ""
3249
3250 #. type: TH
3251 #: fedora-44 opensuse-leap-16-1 opensuse-tumbleweed
3252 #, no-wrap
3253 msgid "perl v5.42.1"
3254 msgstr ""
3255
3256 #. type: Plain text
3257 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3258 #: opensuse-tumbleweed
3259 msgid ""
3260 "Many of Perl\\*(Aqs syntactic elements are B<optional>. Rather than "
3261 "requiring you to put parentheses around every function call and declare "
3262 "every variable, you can often leave such explicit elements off and Perl will "
3263 "figure out what you meant. This is known as B<Do What I Mean>, abbreviated "
3264 "B<DWIM>. It allows programmers to be B<lazy> and to code in a style with "
3265 "which they are comfortable."
3266 msgstr ""
3267
3268 #. type: Plain text
3269 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3270 #: opensuse-tumbleweed
3271 msgid ""
3272 "The only things you need to declare in Perl are report formats and "
3273 "subroutines (and sometimes not even subroutines). A scalar variable holds "
3274 "the undefined value (CW<\\*(C`undef\\*(C'>) until it has been assigned a "
3275 "defined value, which is anything other than CW<\\*(C`undef\\*(C'>. When "
3276 "used as a number, \\&CW<\\*(C`undef\\*(C'> is treated as CW<0>; when used as "
3277 "a string, it is treated as the empty string, CW<\"\">; and when used as a "
3278 "reference that isn\\*(Aqt being assigned to, it is treated as an error. If "
3279 "you enable warnings, you\\*(Aqll be notified of an uninitialized value "
3280 "whenever you treat \\&CW<\\*(C`undef\\*(C'> as a string or a number. Well, "
3281 "usually. Boolean contexts, such as:"
3282 msgstr ""
3283
3284 #. type: Plain text
3285 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3286 #: opensuse-tumbleweed
3287 msgid ""
3288 "A declaration can be put anywhere a statement can, but has no effect on the "
3289 "execution of the primary sequence of statements: declarations all take "
3290 "effect at compile time. All declarations are typically put at the beginning "
3291 "or the end of the script. However, if you\\*(Aqre using lexically-scoped "
3292 "private variables created with CW<my()>, \\&CW<state()>, or CW<our()>, "
3293 "you\\*(Aqll have to make sure your format or subroutine definition is within "
3294 "the same block scope as the B<my()> if you expect to be able to access those "
3295 "private variables."
3296 msgstr ""
3297
3298 #. type: Plain text
3299 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3300 #: opensuse-tumbleweed
3301 msgid ""
3302 "That now parses as you\\*(Aqd expect, but you still ought to get in the "
3303 "habit of using parentheses in that situation. For more on prototypes, see "
3304 "perlsub."
3305 msgstr ""
3306
3307 #. type: Plain text
3308 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3309 #: opensuse-tumbleweed
3310 msgid ""
3311 "The only kind of simple statement is an expression evaluated for its side-"
3312 "effects. Every simple statement must be terminated with a semicolon, unless "
3313 "it is the final statement in a block, in which case the semicolon is "
3314 "optional. But put the semicolon in anyway if the block takes up more than "
3315 "one line, because you may eventually add another line. Note that there are "
3316 "operators like CW<\\*(C`eval {}\\*(C'>, CW<\\*(C`sub {}\\*(C'>, and "
3317 "\\&CW<\\*(C`do {}\\*(C'> that I<look> like compound statements, but "
3318 "aren\\*(Aqt--they\\*(Aqre just TERMs in an expression--and thus need an "
3319 "explicit termination when used as the last item in a statement."
3320 msgstr ""
3321
3322 #. type: Plain text
3323 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3324 #: opensuse-tumbleweed
3325 msgid ""
3326 "See \"do\" in perlfunc. Note also that the loop control statements "
3327 "described later will I<NOT> work in this construct, because modifiers "
3328 "don\\*(Aqt take loop labels. Sorry. You can always put another block "
3329 "inside of it (for CW<\\*(C`next\\*(C'>/CW<\\*(C`redo\\*(C'>) or around it "
3330 "(for CW<\\*(C`last\\*(C'>) to do that sort of thing."
3331 msgstr ""
3332
3333 #. type: Plain text
3334 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3335 #: opensuse-tumbleweed
3336 msgid ""
3337 "\\&B<NOTE:> The behaviour of a CW<\\*(C`my\\*(C'>, CW<\\*(C`state\\*(C'>, or "
3338 "\\&CW<\\*(C`our\\*(C'> modified with a statement modifier conditional or "
3339 "loop construct (for example, CW<\\*(C`my $x if ...\\*(C'>) is "
3340 "\\&B<undefined>. The value of the CW<\\*(C`my\\*(C'> variable may be "
3341 "CW<\\*(C`undef\\*(C'>, any previously assigned value, or possibly anything "
3342 "else. Don\\*(Aqt rely on it. Future versions of perl might do something "
3343 "different from the version of perl you try it out on. Here be dragons."
3344 msgstr ""
3345
3346 #. type: Plain text
3347 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3348 #: opensuse-tumbleweed
3349 msgid ""
3350 "Under the current implementation, the CW<\\*(C`foreach\\*(C'> loop can be "
3351 "anywhere within the CW<\\*(C`when\\*(C'> modifier\\*(Aqs dynamic scope, but "
3352 "must be within the CW<\\*(C`given\\*(C'> block\\*(Aqs lexical scope. This "
3353 "restriction may be relaxed in a future release. See \"Switch Statements\" "
3354 "below."
3355 msgstr ""
3356
3357 #. type: Plain text
3358 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3359 #: opensuse-tumbleweed
3360 msgid ""
3361 "The CW<\\*(C`if\\*(C'> statement is straightforward. Because BLOCKs are "
3362 "always bounded by curly brackets, there is never any ambiguity about which "
3363 "\\&CW<\\*(C`if\\*(C'> an CW<\\*(C`else\\*(C'> goes with. If you use "
3364 "CW<\\*(C`unless\\*(C'> in place of CW<\\*(C`if\\*(C'>, the sense of the test "
3365 "is reversed. Like CW<\\*(C`if\\*(C'>, CW<\\*(C`unless\\*(C'> can be "
3366 "followed by CW<\\*(C`else\\*(C'>. CW<\\*(C`unless\\*(C'> can even be "
3367 "followed by one or more CW<\\*(C`elsif\\*(C'> statements, though you may "
3368 "want to think twice before using that particular language construct, as "
3369 "everyone reading your code will have to think at least twice before they can "
3370 "understand what\\*(Aqs going on."
3371 msgstr ""
3372
3373 #. type: Plain text
3374 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3375 #: opensuse-tumbleweed
3376 msgid ""
3377 "The CW<\\*(C`while\\*(C'> statement executes the block as long as the "
3378 "expression is true. The CW<\\*(C`until\\*(C'> statement executes the block "
3379 "as long as the expression is false. The LABEL is optional, and if present, "
3380 "consists of an identifier followed by a colon. The LABEL identifies the "
3381 "loop for the loop control statements CW<\\*(C`next\\*(C'>, "
3382 "CW<\\*(C`last\\*(C'>, and CW<\\*(C`redo\\*(C'>. If the LABEL is omitted, "
3383 "the loop control statement refers to the innermost enclosing loop. This may "
3384 "include dynamically searching through your call-stack at run time to find "
3385 "the LABEL. Such desperate behavior triggers a warning if you use the "
3386 "CW<\\*(C`use warnings\\*(C'> pragma or the B<-w> flag. If more than one "
3387 "label with the same name occurs, any reference to that name refers to the "
3388 "one labelling the innermost enclosing loop."
3389 msgstr ""
3390
3391 #. type: Plain text
3392 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3393 #: opensuse-tumbleweed
3394 msgid ""
3395 "If the condition expression of a CW<\\*(C`while\\*(C'> statement is based on "
3396 "any of a group of iterative expression types then it gets some magic "
3397 "treatment. The affected iterative expression types are "
3398 "CW<\\*(C`readline\\*(C'>, the CW<\\*(C`E<lt>FILEHANDLEE<gt>\\*(C'> input "
3399 "operator, CW<\\*(C`readdir\\*(C'>, CW<\\*(C`glob\\*(C'>, the "
3400 "CW<\\*(C`E<lt>PATTERNE<gt>\\*(C'> globbing operator, and "
3401 "CW<\\*(C`each\\*(C'>. If the condition expression is one of these "
3402 "expression types, then the value yielded by the iterative operator will be "
3403 "implicitly assigned to CW<$_>. If the condition expression is one of these "
3404 "expression types or an explicit assignment of one of them to a scalar, then "
3405 "the condition actually tests for definedness of the expression\\*(Aqs value, "
3406 "not for its regular truth value."
3407 msgstr ""
3408
3409 #. type: Plain text
3410 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3411 #: opensuse-tumbleweed
3412 msgid ""
3413 "Extension modules can also hook into the Perl parser to define new kinds of "
3414 "compound statements. These are introduced by a keyword which the extension "
3415 "recognizes, and the syntax following the keyword is defined entirely by the "
3416 "extension. If you are an implementor, see \"PL_keyword_plugin\" in perlapi "
3417 "for the mechanism. If you are using such a module, see the module\\*(Aqs "
3418 "documentation for details of the syntax that it defines."
3419 msgstr ""
3420
3421 #. type: Plain text
3422 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3423 #: opensuse-tumbleweed
3424 msgid ""
3425 "Loop control statements don\\*(Aqt work in an CW<\\*(C`if\\*(C'> or "
3426 "CW<\\*(C`unless\\*(C'>, since they aren\\*(Aqt loops. You can double the "
3427 "braces to make them such, though."
3428 msgstr ""
3429
3430 #. type: Plain text
3431 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3432 #: opensuse-tumbleweed
3433 msgid ""
3434 "Perl\\*(Aqs C-style CW<\\*(C`for\\*(C'> loop works like the corresponding "
3435 "CW<\\*(C`while\\*(C'> loop; that means that this:"
3436 msgstr ""
3437
3438 #. type: Plain text
3439 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3440 #: opensuse-tumbleweed
3441 msgid ""
3442 "Besides the normal array index looping, CW<\\*(C`for\\*(C'> can lend itself "
3443 "to many other interesting applications. Here\\*(Aqs one that avoids the "
3444 "problem you get into if you explicitly test for end-of-file on an "
3445 "interactive file descriptor causing your program to appear to hang."
3446 msgstr ""
3447
3448 #. type: Plain text
3449 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3450 #: opensuse-tumbleweed
3451 msgid ""
3452 "The CW<\\*(C`foreach\\*(C'> loop iterates over a normal list value and sets "
3453 "the scalar variable VAR to be each element of the list in turn. If the "
3454 "variable is preceded with the keyword CW<\\*(C`my\\*(C'>, then it is "
3455 "lexically scoped, and is therefore visible only within the loop. Otherwise, "
3456 "the variable is implicitly local to the loop and regains its former value "
3457 "upon exiting the loop. If the variable was previously declared with "
3458 "CW<\\*(C`my\\*(C'>, it uses that variable instead of the global one, but "
3459 "it\\*(Aqs still localized to the loop. This implicit localization occurs "
3460 "I<only> for non C-style loops."
3461 msgstr ""
3462
3463 #. type: Plain text
3464 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3465 #: opensuse-tumbleweed
3466 msgid ""
3467 "If any element of LIST is an lvalue, you can modify it by modifying VAR "
3468 "inside the loop. Conversely, if any element of LIST is NOT an lvalue, any "
3469 "attempt to modify that element will fail. In other words, the "
3470 "CW<\\*(C`foreach\\*(C'> loop index variable is an implicit alias for each "
3471 "item in the list that you\\*(Aqre looping over."
3472 msgstr ""
3473
3474 #. type: Plain text
3475 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3476 #: opensuse-tumbleweed
3477 msgid ""
3478 "If any part of LIST is an array, CW<\\*(C`foreach\\*(C'> will get very "
3479 "confused if you add or remove elements within the loop body, for example "
3480 "with \\&CW<\\*(C`splice\\*(C'>. So don\\*(Aqt do that."
3481 msgstr ""
3482
3483 #. type: Plain text
3484 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3485 #: opensuse-tumbleweed
3486 msgid ""
3487 "\\&CW<\\*(C`foreach\\*(C'> probably won\\*(Aqt do what you expect if VAR is "
3488 "a tied or other special variable. Don\\*(Aqt do that either."
3489 msgstr ""
3490
3491 #. type: Plain text
3492 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3493 #: opensuse-tumbleweed
3494 msgid ""
3495 "As of Perl 5.22, there is an experimental variant of this loop that accepts "
3496 "a variable preceded by a backslash for VAR, in which case the items in the "
3497 "LIST must be references. The backslashed variable will become an alias to "
3498 "each referenced item in the LIST, which must be of the correct type. The "
3499 "variable needn\\*(Aqt be a scalar in this case, and the backslash may be "
3500 "followed by CW<\\*(C`my\\*(C'>. To use this form, you must enable the "
3501 "CW<\\*(C`refaliasing\\*(C'> feature via CW<\\*(C`use feature\\*(C'>. (See "
3502 "feature. See also \"Assigning to References\" in perlref.)"
3503 msgstr ""
3504
3505 #. type: Plain text
3506 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3507 #: opensuse-tumbleweed
3508 msgid ""
3509 "As of Perl 5.36, you can iterate over multiple values at a time. You can "
3510 "only iterate with lexical scalars as the iterator variables - unlike list "
3511 "assignment, it\\*(Aqs not possible to use CW<\\*(C`undef\\*(C'> to signify a "
3512 "value that isn\\*(Aqt wanted. This is a limitation of the current "
3513 "implementation, and might be changed in the future."
3514 msgstr ""
3515
3516 #. type: Plain text
3517 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3518 #: opensuse-tumbleweed
3519 msgid ""
3520 "If the size of the LIST is not an exact multiple of the number of iterator "
3521 "variables, then on the last iteration the \"excess\" iterator variables are "
3522 "aliases to CW<\\*(C`undef\\*(C'>, as if the LIST had CW<\\*(C`, undef\\*(C'> "
3523 "appended as many times as needed for its length to become an exact "
3524 "multiple. This happens whether LIST is a literal LIST or an array - i.e. "
3525 "arrays are not extended if their size is not a multiple of the iteration "
3526 "size, consistent with iterating an array one-at-a-time. As these padding "
3527 "elements are not lvalues, attempting to modify them will fail, consistent "
3528 "with the behaviour when iterating a list with literal "
3529 "CW<\\*(C`undef\\*(C'>s. If this is not the behaviour you desire, then "
3530 "before the loop starts either explicitly extend your array to be an exact "
3531 "multiple, or explicitly throw an exception."
3532 msgstr ""
3533
3534 #. type: Plain text
3535 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3536 #: opensuse-tumbleweed
3537 msgid ""
3538 "Here\\*(Aqs how a C programmer might code up a particular algorithm in Perl:"
3539 msgstr ""
3540
3541 #. type: Plain text
3542 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3543 #: opensuse-tumbleweed
3544 msgid ""
3545 "Whereas here\\*(Aqs how a Perl programmer more comfortable with the idiom "
3546 "might do it:"
3547 msgstr ""
3548
3549 #. type: Plain text
3550 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3551 #: opensuse-tumbleweed
3552 msgid ""
3553 "See how much easier this is? It\\*(Aqs cleaner, safer, and faster. "
3554 "It\\*(Aqs cleaner because it\\*(Aqs less noisy. It\\*(Aqs safer because if "
3555 "code gets added between the inner and outer loops later on, the new code "
3556 "won\\*(Aqt be accidentally executed. The CW<\\*(C`next\\*(C'> explicitly "
3557 "iterates the other loop rather than merely terminating the inner one. And "
3558 "it\\*(Aqs faster because Perl executes a CW<\\*(C`foreach\\*(C'> statement "
3559 "more rapidly than it would the equivalent C-style CW<\\*(C`for\\*(C'> loop."
3560 msgstr ""
3561
3562 #. type: Plain text
3563 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3564 #: opensuse-tumbleweed
3565 msgid ""
3566 "A BLOCK by itself (labeled or not) is semantically equivalent to a loop that "
3567 "executes once. Thus you can use any of the loop control statements in it to "
3568 "leave or restart the block. (Note that this is \\&I<NOT> true in "
3569 "CW<\\*(C`eval{}\\*(C'>, CW<\\*(C`sub{}\\*(C'>, or, contrary to popular "
3570 "belief, \\&CW<\\*(C`do{}\\*(C'> blocks, which do I<NOT> count as loops.) "
3571 "The CW<\\*(C`continue\\*(C'> block is optional."
3572 msgstr ""
3573
3574 #. type: Plain text
3575 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3576 #: opensuse-tumbleweed
3577 msgid ""
3578 "You\\*(Aqll also find that CW<\\*(C`foreach\\*(C'> loop used to create a "
3579 "topicalizer and a switch:"
3580 msgstr ""
3581
3582 #. type: Plain text
3583 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3584 #: opensuse-tumbleweed
3585 msgid ""
3586 "The CW<\\*(C`switch\\*(C'> feature is discouraged for new code and is "
3587 "retained for backward compatibility."
3588 msgstr ""
3589
3590 #. type: Plain text
3591 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3592 #: opensuse-tumbleweed
3593 msgid ""
3594 "Starting from Perl 5.10.1 (well, 5.10.0, but it didn\\*(Aqt work right), you "
3595 "can say"
3596 msgstr ""
3597
3598 #. type: Plain text
3599 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3600 #: opensuse-tumbleweed
3601 msgid ""
3602 "to enable the switch feature. This is loosely based on an old version of a "
3603 "Raku proposal, but it no longer resembles the Raku construct. You also get "
3604 "the switch feature whenever you declare that your code prefers to run under "
3605 "a version of Perl between 5.10 and 5.34. For example:"
3606 msgstr ""
3607
3608 #. type: Plain text
3609 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3610 #: opensuse-tumbleweed
3611 msgid ""
3612 "Under the \"switch\" feature, Perl gains the keywords "
3613 "\\&CW<\\*(C`given\\*(C'>, CW<\\*(C`when\\*(C'>, CW<\\*(C`default\\*(C'>, "
3614 "CW<\\*(C`continue\\*(C'>, and CW<\\*(C`break\\*(C'>. Starting from Perl "
3615 "5.16, one can prefix the switch keywords with CW<\\*(C`CORE::\\*(C'> to "
3616 "access the feature without a CW<\\*(C`use feature\\*(C'> statement. The "
3617 "keywords CW<\\*(C`given\\*(C'> and \\&CW<\\*(C`when\\*(C'> are analogous to "
3618 "CW<\\*(C`switch\\*(C'> and \\&CW<\\*(C`case\\*(C'> in other languages -- "
3619 "though CW<\\*(C`continue\\*(C'> is not -- so the code in the previous "
3620 "section could be rewritten as"
3621 msgstr ""
3622
3623 #. type: Plain text
3624 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3625 #: opensuse-tumbleweed
3626 msgid ""
3627 "The CW<\\*(C`foreach\\*(C'> is another way to set a topicalizer. If you "
3628 "wish to use CW<\\*(C`given\\*(C'>, that could be written like this:"
3629 msgstr ""
3630
3631 #. type: Plain text
3632 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3633 #: opensuse-tumbleweed
3634 msgid "Or if you don\\*(Aqt care to play it safe, like this:"
3635 msgstr ""
3636
3637 #. type: Plain text
3638 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3639 #: opensuse-tumbleweed
3640 msgid ""
3641 "Although not for the faint of heart, Perl does support a "
3642 "CW<\\*(C`goto\\*(C'> statement. There are three forms: CW<\\*(C`goto\\*(C'>-"
3643 "LABEL, CW<\\*(C`goto\\*(C'>-EXPR, and \\&CW<\\*(C`goto\\*(C'>-&NAME. A "
3644 "loop\\*(Aqs LABEL is not actually a valid target for a CW<\\*(C`goto\\*(C'>; "
3645 "it\\*(Aqs just the name of the loop."
3646 msgstr ""
3647
3648 #. type: Plain text
3649 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3650 #: opensuse-tumbleweed
3651 msgid ""
3652 "The CW<\\*(C`goto\\*(C'>-LABEL form finds the statement labeled with LABEL "
3653 "and resumes execution there. It may not be used to go into any construct "
3654 "that requires initialization, such as a subroutine or a "
3655 "CW<\\*(C`foreach\\*(C'> loop. It also can\\*(Aqt be used to go into a "
3656 "construct that is optimized away. It can be used to go almost anywhere else "
3657 "within the dynamic scope, including out of subroutines, but it\\*(Aqs "
3658 "usually better to use some other construct such as CW<\\*(C`last\\*(C'> or "
3659 "CW<\\*(C`die\\*(C'>. The author of Perl has never felt the need to use this "
3660 "form of CW<\\*(C`goto\\*(C'> (in Perl, that is--C is another matter)."
3661 msgstr ""
3662
3663 #. type: Plain text
3664 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3665 #: opensuse-tumbleweed
3666 msgid ""
3667 "The CW<\\*(C`goto\\*(C'>-EXPR form expects a label name, whose scope will be "
3668 "resolved dynamically. This allows for computed CW<\\*(C`goto\\*(C'>s per "
3669 "FORTRAN, but isn\\*(Aqt necessarily recommended if you\\*(Aqre optimizing "
3670 "for maintainability:"
3671 msgstr ""
3672
3673 #. type: Plain text
3674 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3675 #: opensuse-tumbleweed
3676 msgid ""
3677 "In almost all cases like this, it\\*(Aqs usually a far, far better idea to "
3678 "use the structured control flow mechanisms of CW<\\*(C`next\\*(C'>, "
3679 "CW<\\*(C`last\\*(C'>, or CW<\\*(C`redo\\*(C'> instead of resorting to a "
3680 "CW<\\*(C`goto\\*(C'>. For certain applications, the catch and throw pair of "
3681 "\\&CW<\\*(C`eval{}\\*(C'> and B<die()> for exception processing can also be "
3682 "a prudent approach."
3683 msgstr ""
3684
3685 #. type: Plain text
3686 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3687 #: opensuse-tumbleweed
3688 msgid ""
3689 "Beginning in Perl 5.12, Perl accepts an ellipsis, \"CW<\\*(C`...\\*(C'>\", "
3690 "as a placeholder for code that you haven\\*(Aqt implemented yet. When Perl "
3691 "5.12 or later encounters an ellipsis statement, it parses this without "
3692 "error, but if and when you should actually try to execute it, Perl throws an "
3693 "exception with the text CW<\\*(C`Unimplemented\\*(C'>:"
3694 msgstr ""
3695
3696 #. type: Plain text
3697 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3698 #: opensuse-tumbleweed
3699 msgid ""
3700 "There are some cases where Perl can\\*(Aqt immediately tell the difference "
3701 "between an expression and a statement. For instance, the syntax for a block "
3702 "and an anonymous hash reference constructor look the same unless "
3703 "there\\*(Aqs something in the braces to give Perl a hint. The ellipsis is a "
3704 "syntax error if Perl doesn\\*(Aqt guess that the CW<\\*(C`{ ... }\\*(C'> is "
3705 "a block. Inside your block, you can use a CW<\\*(C`;\\*(C'> before the "
3706 "ellipsis to denote that the \\&CW<\\*(C`{ ... }\\*(C'> is a block and not a "
3707 "hash reference constructor."
3708 msgstr ""
3709
3710 #. type: Plain text
3711 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3712 #: opensuse-tumbleweed
3713 msgid ""
3714 "Perl has a mechanism for intermixing documentation with source code. While "
3715 "it\\*(Aqs expecting the beginning of a new statement, if the compiler "
3716 "encounters a line that begins with an equal sign and a word, like this"
3717 msgstr ""
3718
3719 #. type: Plain text
3720 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3721 #: opensuse-tumbleweed
3722 msgid ""
3723 "You probably shouldn\\*(Aqt rely upon the CW<warn()> being podded out "
3724 "forever. Not all pod translators are well-behaved in this regard, and "
3725 "perhaps the compiler will become pickier."
3726 msgstr ""
3727
3728 #. type: Plain text
3729 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3730 #: opensuse-tumbleweed
3731 msgid ""
3732 "Perl can process line directives, much like the C preprocessor. Using this, "
3733 "one can control Perl\\*(Aqs idea of filenames and line numbers in error or "
3734 "warning messages (especially for strings that are processed with "
3735 "CW<eval()>). The syntax for this mechanism is almost the same as for most C "
3736 "preprocessors: it matches the regular expression"
3737 msgstr ""
3738
3739 #. type: Plain text
3740 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3741 #: opensuse-tumbleweed
3742 msgid ""
3743 "There is a fairly obvious gotcha included with the line directive: Debuggers "
3744 "and profilers will only show the last source line to appear at a particular "
3745 "line number in a given file. Care should be taken not to cause line number "
3746 "collisions in code you\\*(Aqd like to debug later."
3747 msgstr ""
3748
3749 #. type: Plain text
3750 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3751 #: opensuse-tumbleweed
3752 msgid ""
3753 "These rules are complicated, but the goal is for them to do what you want "
3754 "(even if you don\\*(Aqt quite understand why they are doing it). For "
3755 "example:"
3756 msgstr ""
3757
3758 #. type: Plain text
3759 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3760 #: opensuse-tumbleweed
3761 msgid ""
3762 "Tautologous boolean operators are still going to be optimized away. "
3763 "Don\\*(Aqt be tempted to write"
3764 msgstr ""
3765
3766 #. type: Plain text
3767 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3768 #: opensuse-tumbleweed
3769 msgid ""
3770 "This is somewhat equivalent to the C-style switch statement\\*(Aqs "
3771 "fallthrough functionality (not to be confused with I<Perl\\*(Aqs> "
3772 "fallthrough functionality--see below), wherein the same block is used for "
3773 "several \\&CW<\\*(C`case\\*(C'> statements."
3774 msgstr ""
3775
3776 #. type: Plain text
3777 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3778 #: opensuse-tumbleweed
3779 msgid ""
3780 "When a CW<\\*(C`given\\*(C'> statement is also a valid expression (for "
3781 "example, when it\\*(Aqs the last statement of a block), it evaluates to:"
3782 msgstr ""
3783
3784 #. type: Plain text
3785 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3786 #: opensuse-tumbleweed
3787 msgid ""
3788 "Currently, CW<\\*(C`given\\*(C'> blocks can\\*(Aqt always be used as proper "
3789 "expressions. This may be addressed in a future version of Perl."
3790 msgstr ""
3791
3792 #. type: Plain text
3793 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3794 #: opensuse-tumbleweed
3795 msgid ""
3796 "Instead of using CW<given()>, you can use a CW<foreach()> loop. For "
3797 "example, here\\*(Aqs one way to count how many times a particular string "
3798 "occurs in an array:"
3799 msgstr ""
3800
3801 #. type: Plain text
3802 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3803 #: opensuse-tumbleweed
3804 msgid ""
3805 "At the end of all CW<\\*(C`when\\*(C'> blocks, there is an implicit "
3806 "CW<\\*(C`next\\*(C'>. You can override that with an explicit "
3807 "CW<\\*(C`last\\*(C'> if you\\*(Aqre interested in only the first match alone."
3808 msgstr ""
3809
3810 #. type: Plain text
3811 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3812 #: opensuse-tumbleweed
3813 msgid ""
3814 "This doesn\\*(Aqt work if you explicitly specify a loop variable, as in "
3815 "CW<\\*(C`for $item (@array)\\*(C'>. You have to use the default variable "
3816 "CW<$_>."
3817 msgstr ""
3818
3819 #. type: Plain text
3820 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3821 #: opensuse-tumbleweed
3822 msgid ""
3823 "The Perl 5 smartmatch and CW<\\*(C`given\\*(C'>/CW<\\*(C`when\\*(C'> "
3824 "constructs are not compatible with their Raku analogues. The most visible "
3825 "difference and least important difference is that, in Perl 5, parentheses "
3826 "are required around the argument to CW<given()> and CW<when()> (except when "
3827 "this last one is used as a statement modifier). Parentheses in Raku are "
3828 "always optional in a control construct such as CW<if()>, CW<while()>, or "
3829 "CW<when()>; they can\\*(Aqt be made optional in Perl 5 without a great deal "
3830 "of potential confusion, because Perl 5 would parse the expression"
3831 msgstr ""
3832
3833 #. type: Plain text
3834 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3835 #: opensuse-tumbleweed
3836 msgid ""
3837 "But it doesn\\*(Aqt work at all in Raku. Instead, you should use the "
3838 "(parallelizable) CW<\\*(C`any\\*(C'> operator:"
3839 msgstr ""
3840
3841 #. type: Plain text
3842 #: fedora-44 fedora-rawhide mageia-cauldron opensuse-leap-16-1
3843 #: opensuse-tumbleweed
3844 msgid ""
3845 "The table of smartmatches in \"Smartmatch Operator\" in perlop is not "
3846 "identical to that proposed by the Raku specification, mainly due to "
3847 "differences between Raku\\*(Aqs and Perl 5\\*(Aqs data models, but also "
3848 "because the Raku spec has changed since Perl 5 rushed into early adoption."
3849 msgstr ""
3850
3851 #. type: TH
3852 #: fedora-rawhide
3853 #, no-wrap
3854 msgid "2026-03-30"
3855 msgstr ""
3856
3857 #. type: TH
3858 #: fedora-rawhide
3859 #, no-wrap
3860 msgid "perl v5.42.2"
3861 msgstr ""
3862
3863 #. type: TH
3864 #: mageia-cauldron
3865 #, no-wrap
3866 msgid "2025-06-24"
3867 msgstr ""
3868
3869 #. type: TH
3870 #: mageia-cauldron
3871 #, no-wrap
3872 msgid "perl v5.42.0"
3873 msgstr ""