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

Hi, everyone ! Recently, the SYNOPSIS syntax has bothered me a lot. Please give me your guidance.

For example, when you see Data::Dumper documentation on http://perldoc.perl.org/Data/Dumper.html

You see the following Synopsis: 
print Data::Dumper->Dump([$foo, $bar], [qw(foo *ary)]);

Can you please tell me what [qw(foo *ary)] does mean?
Is it anonymous reference of an array ? what is "*ary" ?
Thank you in advance.

Replies are listed 'Best First'.
Re: SYNOPSIS question on Perl manauls
by moritz (Cardinal) on Jan 11, 2012 at 18:31 UTC

    qw(...) returns a list of whitespace separated strings. So at first the *ary is only a string.

    It's Data::Dumper that's giving the string a special meaning. The second argument to Dump is an array ref of variable names. When you pass in *ary, it makes the result a scalar if the data to dump is an ordinary scalar, but it because @ary if the data is an array reference:

    $ perl -MData::Dumper -wE 'print Data::Dumper->Dump([[1, 2]], [q[$foo] +])' $foo = [ 1, 2 ]; $ perl -MData::Dumper -wE 'print Data::Dumper->Dump([[1, 2]], [q[*foo] +])' @foo = ( 1, 2 ); $ perl -MData::Dumper -wE 'print Data::Dumper->Dump([{ a => 2}], [q[*f +oo]])' %foo = ( 'a' => 2 );

    I guess that's in analogy to the typeglob syntax explained in perlmod.

Re: SYNOPSIS question on Perl manauls
by Corion (Patriarch) on Jan 11, 2012 at 18:34 UTC

    See perlop on qw() (under "Quotes and Quote-like operators"), and perlref on [...].