in reply to Re^4: Referencing in Function not working correctly.
in thread Referencing in Function not working correctly.

Yes @x gets initialized there, but ("z", "y", "z") is different than (), and my @x is different than my ( @x, @y, @z ).

What do you think my ( @x, @y, @z ) = ("z", "y", "z"); does?

Replies are listed 'Best First'.
Re^6: Referencing in Function not working correctly.
by mr_p (Scribe) on Apr 02, 2010 at 19:49 UTC
    I am sorry I have no idea what that does. Please explain. My guess is @x[0]=z, @y[0]=y and @z[0]=z.

    When I had the below statement, I was trying to create and initialize values of all variables.

    my (%Aseen, %Bseen, %count, @isec, @diff, @union, @aonly) = ();

    Please let me know what I'm doing wrong.

    Thanks for your help.

      :)

      perl -MData::Dumper -lwe 'my ( @x, @y, @z ) = ("z", "y", "z"); print D +umper(\(@x,@y,@z))' $VAR1 = [ 'z', 'y', 'z' ]; $VAR2 = []; $VAR3 = [];
      my (%Aseen, %Bseen, %count, @isec, @diff, @union, @aonly);

      They all are declared empty. No need to be explicit about it; and as the example above shows, that form of being explicit won't do what you might think anyway.

      When you have an aggregate (array or hash) in a list that variable will be assigned all the values.    So:

      my ( @x, @y, @z ) = ("z", "y", "z");

      Is exactly the same as:

      my @x = ("z", "y", "z"); my ( @y, @z );

        So, I don't get what is wrong with me doing

        (%count, @isec, @diff, @union, @aonly) = ();

        to initialize?