7stud has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
Here is the code I have a question about:
sub do_stuff { my($x) = ($_[0] || 0); ... }
Do the parentheses around $x do anything? It seems to me that the rhs will always be a scalar, and these are equivalent:
my $x = 10; print $x, "\n"; my ($y) = 10; print $y, "\n"; --output:-- 10 10
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: list context
by chromatic (Archbishop) on Dec 06, 2010 at 22:56 UTC | |
by ikegami (Patriarch) on Dec 07, 2010 at 00:06 UTC | |
by chromatic (Archbishop) on Dec 07, 2010 at 00:13 UTC | |
|
Re: list context
by ikegami (Patriarch) on Dec 07, 2010 at 00:13 UTC | |
|
Re: list context
by JavaFan (Canon) on Dec 06, 2010 at 23:09 UTC | |
by ikegami (Patriarch) on Dec 07, 2010 at 00:29 UTC | |
|
Re: list context
by chrestomanci (Priest) on Dec 06, 2010 at 22:26 UTC | |
|
Re: list context (iterators)
by LanX (Saint) on Dec 07, 2010 at 00:12 UTC |