In a message dated 6/4/2004 3:31:51 PM Eastern Standard Time, 
[EMAIL PROTECTED] writes:
>I've read that
>
>@a = undef;
>
>creates an array with 1 empty element.  Why does it do so?  (I'm trying to
>learn to think like Perl, not just learn it by rote.)
>

The best way to think of it, I think, is that parenthesis are optional for 
lists. It's necessary, however, for more than one item when assigning a list to 
an array because precedence dictates that the comma (,) binds looser than the 
equal sign (=). 

So 
@a = undef;
is actually evaluated as 
@a = (undef);

and something like 
@a = undef, 2;
is actually evaluated as 
(@a = (undef)), 2;


-will 
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite 

-- 
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