@@ -477,6 +477,13 @@ say $foo; # Exception! "Variable '$foo' is not declared"
477
477
This dies because C < $foo > is only defined as long as we are in the same
478
478
scope.
479
479
480
+ In order to lexically scope more than one variable at the same time, surround
481
+ the variables with parentheses:
482
+
483
+ my ( $foo, $bar );
484
+
485
+ see also L < Declaring a list of variables lexically or package scoped|/variables#list_of_variables_my_our > .
486
+
480
487
Additionally, lexical scoping means that variables can be temporarily
481
488
redefined in a new scope:
482
489
@@ -529,12 +536,21 @@ introduce an alias into the symbol table.
529
536
530
537
# Available as $M::Var here.
531
538
539
+ In order to package scope more than one variable at the same time, surround
540
+ the variables with parentheses:
541
+
542
+ our ( $foo, $bar );
543
+
544
+ see also L < Declaring a list of variables lexically or package scoped|/variables#list_of_variables_my_our > .
545
+
546
+
547
+ X < list_of_variables_my_our|Declaring a list of variables lexically (C < my > ) or package (C < our > ) scoped >
532
548
= head2 Declaring a list of variables lexically (C < my > ) or package (C < our > ) scoped
533
549
534
550
It is possible to scope more than one variable at a time, but both C < my >
535
551
and C < our > require variables to be placed into parentheses:
536
552
537
- my (@a, $s, %h); # same as my @a; my $s; my %h;
553
+ my (@a, $s, %h); # same as my @a; my $s; my %h;
538
554
our (@aa, $ss, %hh); # same as our @aa; our $ss; our %hh;
539
555
540
556
This can be used in conjunction with X « destructuring assignment » . Any
0 commit comments