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

Can someone tell me what the difference is between these two scalar declarations:
my $foo = 'bah' my ($foo) = 'bah'

Thanks

Replies are listed 'Best First'.
Re: scalars in parens ?
by lidden (Curate) on Apr 23, 2006 at 19:45 UTC
    Context, with parens you assign to a list. It does not matter in your case, but:
    my $foo = 'bah' =~ /(a)/; print "$foo\n"; ($foo) = 'bah' =~ /(a)/; print "$foo\n";
Re: scalars in parens ?
by davidrw (Prior) on Apr 23, 2006 at 20:01 UTC
    See the front-paged my $x or my ($x) from earlier this month for lots of good replies, disccusion, and examples.
Re: scalars in parens ?
by McDarren (Abbot) on Apr 24, 2006 at 00:09 UTC