Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Multidimensional Arrays

by CharlesClarkson (Curate)
on Jun 22, 2001 at 11:11 UTC ( #90647=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        my @array = (1, 2, 3, 'four');
  2. or download this
        print $array[0];
              ^
    
  3. or download this
        my @array = (1, 2, 3, 'four');
        my $reference = \@array;
        print $reference;
    
  4. or download this
        ARRAY(0x1a6527c)
  5. or download this
        my @array = (1, 2, 3, 'four');
        my $reference = \@array;
        print $reference;
        push @array, (1 .. 1000);
        $reference = \@array;
        print $reference;
    
  6. or download this
        ARRAY(0x1a6527c)ARRAY(0x1a6527c)
  7. or download this
        my @array = (1, 2, 3, 'four');
        my $reference = \@array;
        print $reference->[0];
    
  8. or download this
        1
  9. or download this
        my @array = (1, 2, 3, 'four');
        my $reference = \@array;
        $reference->[0] = 'one';
        print "@array";
    
  10. or download this
        one 2 3 four
  11. or download this
        my @array = (1, 2, 3, 'four');
        print $array[0];
    
  12. or download this
        1
  13. or download this
        my @array = (1, 2, 3, 'four');
        my $reference = \@array;
        print $reference->[0];
    
  14. or download this
        1
  15. or download this
        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];
    
  16. or download this
        1
  17. or download this
        my @array1 = (1, 2, 3, 'four');
        my $reference1 = \@array1;
    
  18. or download this
        my $reference1 = [1, 2, 3, 'four'];
  19. or download this
        my @array1 = (1, 2, 3, 'four');
        my $reference1 = \@array1;
        my @array2 = ('one', 'two', 'three', 4);
    ...
    
        my @array = ($reference1, $reference2);
        print $array[0]->[0];
    
  20. or download this
        my @array = ( [1, 2, 3, 'four'], ['one', 'two', 'three', 4] );
        print $array[0]->[0];
    
  21. or download this
        1
  22. or download this
        my @array = ([1, 2, 3, 'four'], ['one', 'two', 'three', 4]);
        print $array[0][0];
    
  23. or download this
        1
  24. or download this
        my @shapes = (
                [qw/circle square triangle polygon/],
                [qw/red green blue yellow fuschia/] );
    
  25. or download this
        use Data::Dumper;
        print Dumper \@shapes;
    
  26. or download this
    $VAR1 = [
              [
                'circle',
    ...
                'fuschia'
              ]
            ];
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://90647]
help
Chatterbox?
[erix]: 1=0 is as short as TOP :)
[erix]: "code of someone that died" -- kinda nice if your code stops working too
[erix]: hard to implement, hmm
[Corion]: erix: Well, they also seem to have changed the server, or some software, or whatever, and seem to be in the process of changing the DB schema from having the "username" as primary key to something else.
[Corion]: Far too many things being done at once, or maybe only now has it become apparent that nobody knows that piece of software anymore
[marto]: good morning all

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2017-01-23 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (192 votes). Check out past polls.