ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
8.7 File-Level my( ) VariablesThe use strict;
If you place this pragma at the beginning of your file, you will no longer be able to use variables (scalars, arrays, and hashes) until you have first "declared" them. And you declare them with use strict; my $a; # starts as undef my @b = qw(fred barney betty); # give initial value ... push @b, qw(wilma); # cannot leave her out @c = sort @b; # WILL NOT COMPILE That last statement will be flagged at compile time as an error, because it referred to a variable that had not previously been declared with The advantages of forcing variable declarations are twofold:
Because of this, many Perl programmers automatically begin every new Perl program with |