in reply to Assign multiple scalars the same value

I've noticed that

my ($a,$b,$c) = "TRUE";

doesn't work

The reason it doesn't work is that my ($a,$b,$c) is, because of the (), effectively an array. Since "true" is a single element, its equivalent to doing

my @badger="true"; foreach (@badger){print "$_\n"}

The following

my ($a,$b,$c) = ("TRUE", "TRUE", "TRUE");

works OK, because the variables on both side of the '=' are arrays - note the ()

Note that I'm not advocating using this last syntax. I agree with diotalevi that it potentially introduces a bug if you don't use enough "TRUE" values. Personally, I favour jdporters syntax, I'm just pointing out why your original failed.

Replies are listed 'Best First'.
Re^2: Assign multiple scalars the same value
by chromatic (Archbishop) on Jan 25, 2005 at 19:30 UTC

    They're lists, not arrays. It's an important distinction; try a list of different elements versus an array of different elements assigned to lists and scalars on the left hand side with and without parenthesis.