in reply to please explain some code

what does & mean in this line of code ?

To Perl, it means "ignore the prototype". To some people, it seems to mean something else I don't know.

Why is variable $dir surrounded by () ?

my $dir = @_; would assign the number of elements in @_ to $dir.

What does [my (@dirs,$list);] do ?

A short way of writing

my @dirs; my $list;

Usually we declare list in bracket on right hand side and that contains values.

This makes no sense. For starters, you can't declare lists since they're not variables.

Where can I find more details about this code ?

my


A question of my own: Why do you add a space in front of every "?"?

Replies are listed 'Best First'.
Re^2: please explain some code
by manishrathi (Beadle) on Jul 18, 2011 at 10:21 UTC
    whats the difference between "my $dir = @_" and "my ($dir) = @_" ?
    If both mean same thing, then why use () around $dir in first case ?
      "my $dir = @_" is scalar context, so $dir will contain number of elements in @_
      "my ($dir) = @_" is list context, so $dir will contain first value of @_ (if exists)