### Multidimensional Arrays

by CharlesClarkson (Curate)
 on Jun 22, 2001 at 11:11 UTC Need Help??

my @array = (1, 2, 3, 'four');
```    print \$array[0];
^
```
```    my @array = (1, 2, 3, 'four');
my \$reference = \@array;
print \$reference;
```
ARRAY(0x1a6527c)
```    my @array = (1, 2, 3, 'four');
my \$reference = \@array;
print \$reference;
push @array, (1 .. 1000);
\$reference = \@array;
print \$reference;
```
ARRAY(0x1a6527c)ARRAY(0x1a6527c)
```    my @array = (1, 2, 3, 'four');
my \$reference = \@array;
print \$reference->[0];
```
1
```    my @array = (1, 2, 3, 'four');
my \$reference = \@array;
\$reference->[0] = 'one';
print "@array";
```
one 2 3 four
```    my @array = (1, 2, 3, 'four');
print \$array[0];
```
1
```    my @array = (1, 2, 3, 'four');
my \$reference = \@array;
print \$reference->[0];
```
1
```    my @array1 = (1, 2, 3, 'four');
my \$reference1 = \@array1;
my @array2 = ('one', 'two', 'three', 4);
...

# this refers to the first item of the first array:
print \$array[0]->[0];
```
1
```    my @array1 = (1, 2, 3, 'four');
my \$reference1 = \@array1;
```
my \$reference1 = [1, 2, 3, 'four'];
```    my @array1 = (1, 2, 3, 'four');
my \$reference1 = \@array1;
my @array2 = ('one', 'two', 'three', 4);
...

my @array = (\$reference1, \$reference2);
print \$array[0]->[0];
```
```    my @array = ( [1, 2, 3, 'four'], ['one', 'two', 'three', 4] );
print \$array[0]->[0];
```
1
```    my @array = ([1, 2, 3, 'four'], ['one', 'two', 'three', 4]);
print \$array[0][0];
```
1
```    my @shapes = (
[qw/circle square triangle polygon/],
[qw/red green blue yellow fuschia/] );
```
```    use Data::Dumper;
print Dumper \@shapes;
```
```\$VAR1 = [
[
'circle',
...
'fuschia'
]
];
```

Create A New User
Node Status?
node history
Node Type: perltutorial [id://90647]
help
Chatterbox?
 [stevieb]: in a C++ header file, if a function declaration is listed twice with each listing containing different params, that's just essentially allowing one function accept two different arg lists, yes? [stevieb]: int func(int x, int y); [stevieb]: int func(int x); [stevieb]: For example

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2017-06-28 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
How many monitors do you use while coding?

Results (653 votes). Check out past polls.