Gunnar Hjalmarsson wrote:
J. Peng wrote:
I'm not sure, but why this can work?
use strict;
use warnings;
use Data::Dumper;
my $y=0;
my @x =(1,2,3) if $y;
print Dumper [EMAIL PROTECTED];
Since $y is false, it seems @x shouldn't be declared.
Please read the last para in the "Statement Modifiers" section in
"perldoc perlrun".
I should add that variable declaration happens at compile time, while
assigning happens at run time.
C:\home>type test.pl
my $var = 123;
BEGIN { print "\$var is $var at compile time.\n" }
print "\$var is $var at run time.\n";
C:\home>test.pl
$var is at compile time.
$var is 123 at run time.
C:\home>
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/