Anonymous user
Creating an Array: Difference between revisions
→[[Perl]]
(Added Toka) |
|||
Line 296:
==[[Perl]]==
[[Category:Perl]]
'''
my @empty;
[0,0,0,0,0,0],▼
# And
my $aref = ['This', 'That', 'And', 'The', 'Other'];
print aref->[2];
# And
▲ print $Array[1][3];
# having to quote like that really sucks, and that's why we got syntactic sugar
push @wakey_wakey, 'spoon';
# add spoon to right-hand side
my $cutlery = pop @wakey_wakey;
# remove spoon
unshift @wakey_wakey, 'cup';
# add cup to left-hand side
my $container = shift @wakey_wakey;
# remove cup
my @multi_dimensional = (
▲ my @Array3 = ();
[qw(a b c d e f g)],
[qw(! $ % & *)],
);
print $multi_dimensional[1][3];
# d
▲ @Array = ('This', 'That', 'And', 'The', 'Other');
my $mdref = [
[qw(a b c d e f g)],
[qw(! $ % & *)],
];
print $mdref->[1][3];
# d
==[[PHP]]==
|