John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
OK, why are we making a fundamental distinction between scalar and list variables via the sigil, when they seem to behave identically? A scalar can hold a list, and the explicit "reference" concept is no longer used, and the only difference is that you can leave off the parens when assigning a literal to the list variable.pugs> my @y= 1,2,3 (1, 2, 3) pugs> @y.WHAT ::Array pugs> my $x= (1,2,3) (1, 2, 3) pugs> $x (1, 2, 3) pugs> $x.WHAT ::Array pugs> my $z= [1,2,3] (1, 2, 3) pugs> $z.WHAT ::Array pugs> $x[1] 2 pugs> @y[1] 2 pugs> $z[1] 2 pugs>
Given that scalers can hold arrays, why bother with making @variables different, or using them in code?
—John
Writing from a comfortable room in 上黑 (Shanghei)上海 (Shanghai)
|
|---|