On 19 March 2010 11:45,  <trapd...@trapd00r.se> wrote:
> On 19/03/10 13:19 +0200, Chris Knipe wrote:
>>
>> my ($foo, $bar) = 1
>>
>> I am getting more and more occurances where when I use the later as above,
>> $bar would not have a defined value...  I'm not quite sure I understand
>> why.
>
> Does;
> my ($foo,$bar) = 1 x 2;
> do what you want?

Probably not:
$ perl foo.pl
11

$ cat foo.pl
my ($foo,$bar) = 1 x 2;
print "$foo\n";
print "$bar\n";

You've concatenated two strings containing '1' into a single scalar
'11' and assigned it to $foo.

You probably meant (1) x 2, and even that is not terribly readable or
maintainable.

Phil

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to