Please use code tags for all code, it makes it a lot easier to read. Anyway:

my (@sargs) = @_;
is it equivalent with : my @sargs = @_; ? (without bracket)
Since @args = already forces list context, yes, they are equivalent. But note that
my $var = @list;
is not equivalent to
my ($var) = @list;
my $config = {"delete" => 0, soFiles => []};
Is it right that $config is a hash table ?
Well, $config is a reference to a hash table; a normal hash is initialized with a list: ( key => value ...) while a reference to an anonymous hash is created with { key => value .. }

is these 2 lines are equivalent ?
my $config = {"delete" => 0, soFiles => }; my $config = {"delete" => 0, "soFiles" => };
Yes, keys that only contain alphanumeric characters can be left unquoted before the => operator.

You should use an even number of element in a hash, though. (there is NO value for the soFiles key in your example. that isn't possible in a hash)

After that, delete is initialized like this :
$config->{delete} = 1; # why -> is it a reference ?
why not to use :
$config{delete} = 1
$config->{ } is used to dereference the reference in $config. the reason that you can't use $config{delete} is because $config{delete} indicates an element in the hash %config, while $config->{delete} indicates an element in the hash pointed to by $config.

You seem to have a reasonable understanding of programming techniques, but a little less sure of Perl itself. You might find the camel book enlightening. Also, putting this at the top of your code will help you spot bugs:

#/usr/bin/perl use strict; use warnings; use diagnostics; # optional; turns on more descriptive warnings

And we don't usually mind questions, so ask away. :-)


In reply to Re: Perl data types and references by Joost
in thread Perl data types and references by thierry

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.