2012年2月10日 星期五

Perl array include array

@a = (1, 2, 3);
@b = (4, 5, 6);

$c[0] = \@a;
$c[1] = \@b;

print $c[0][0];  # result is 1
print $c[0][1];  # result is 2
print $c[0][2];  # result is 3
print $c[1][0];  # result is 4
print $c[1][1];  # result is 5
print $c[1][2];  # result is 6

PS: \@ is a pointer of array.

沒有留言:

張貼留言