[prev] [index] [next]

Arrays (Lists) (cont)

Alternative interpretations for  @a ...

@a = ("abc", 123, 'x');

# numeric context ... gives list length

$n = @a;         #  $n == 3

# string context ... gives space-separated elems

$s = "@a";       #  $s eq "abc 123 x"

# scalar context ... gives list length

$t = @a."";      #  $t eq "3"

# print context ... gives joined elems

print @a;        #  displays "abc123x"

In Perl, interpretation is context-dependent.