Ing. Branislav Gerzo wrote:
JupiterHost.Net [JN], on Thursday, April 28, 2005 at 09:11 (-0500) contributed this to our collective wisdom:
(really beginners) could think "@a" will empty array, which is not true.
JN> yes it is true, they are both empty lists:
@a will not empty array, here it is:
I never said it will empty a list, I'm talking about declaring it intially (IE my @a; vs. my @a = ();) when I brought it up.
# perl -mstrict -MData::Dumper -we 'my @x;my @y = ();print Dumper [EMAIL PROTECTED], [EMAIL PROTECTED];' $VAR1 = []; $VAR2 = []; #
See? No differnece in the array, both *create* an empty list, just my @a; is slightly more efficient.
my @a = q{foo bar}; @a; print @a;
against
my @a = q{foo bar}; @a = ( ); print @a;
I hope you see the difference :)
Yes the difference now you're not talking about declaring the array initially which is what this part of this lame thread is all about.
Apples and Oranges my friend :)
PS - I think you mean qw() not q() as you're only assigning one string of "foo bar" to the array...
# perl -mstrict -MData::Dumper -we 'my @x = q{foo bar};print Dumper [EMAIL PROTECTED];' $VAR1 = [ 'foo bar' ]; #
vs.
# perl -mstrict -MData::Dumper -we 'my @x = qw(foo bar);print Dumper [EMAIL PROTECTED];' $VAR1 = [ 'foo', 'bar' ]; #
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>