> > Zeng Nan [ZN], on Thursday, November 18, 2004 at 13:43 
> (+0800) wrote 
> > these comments:
> > 
> > ZN> As said in "Learning Perl", a perl identifier is "a letter or 
> > ZN> underscore, and then possibly more letters, or digits, or
> underscores".
> > ZN> Because of this, $123 is an invalid name, but why $000 
> or $000000
> works?


  I tried the following code:
#!/usr/bin/perl

use warnings;
use strict;

my $00 = "Two Zeros";
my $000 = "Three Zeros";
my $0000 = "Four Zeros";

print "\$0    = $0\n";
print "\$00   = $00\n";
print "\$000  = $000\n";
print "\$0000 = $0000\n";


  And I got the following output:
Can't use global $00 in "my" at ./zerotest line 6, near "my $00 "
Can't use global $000 in "my" at ./zerotest line 7, near "my $000 "
Can't use global $0000 in "my" at ./zerotest line 8, near "my $0000 "
Execution of ./zerotest aborted due to compilation errors.


  BUT ... When I removed the "warnings" and "strict", and stopped using
"my", it works:

#!/usr/bin/perl

$00 = "Two Zeros";
$000 = "Three Zeros";
$0000 = "Four Zeros";

print "\$0    = $0\n";
print "\$00   = $00\n";
print "\$000  = $000\n";
print "\$0000 = $0000\n";


  The above code produced the following output:
$0    = ./zerotest
$00   = Two Zeros
$000  = Three Zeros
$0000 = Four Zeros

So ... Um, weird!

--Errin

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to