mecrazycoder has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, Whats the difference between
my $root=@_; my ($root)=@_;
. I know both are different but i want to know what does it mean. Thanks

Replies are listed 'Best First'.
Re: Simple one
by Taulmarill (Deacon) on Aug 20, 2009 at 12:47 UTC
    One difference is about context. The first line sets @_ in scalar context, which makes Arrays give back the number of their elements.

    The second line sets the Array in list context, because $root now is in a list. The fact that the list has only one element does not concern @_. In list context, Arrays return all their elements. Since the list has only one element, only the first element of the array is stored.
Re: Simple one
by BioLion (Curate) on Aug 20, 2009 at 12:47 UTC

    I guess you want to know about context? Discussion here and info here.

    Just a something something...
Re: Simple one (sassign vs aassign)
by ikegami (Patriarch) on Aug 20, 2009 at 15:54 UTC
Re: Simple one
by mecrazycoder (Sexton) on Aug 20, 2009 at 12:53 UTC
    Thanks a lot dude
Re: Simple one
by Anonymous Monk on Aug 21, 2009 at 09:24 UTC
    hi my $root=@_; my ($root)=@_; In the first case it will store the length of an array. In the second case it will store the first element of the array.