Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: how to use two dimensional array?

by BillKSmith (Priest)
on Jun 14, 2013 at 10:47 UTC ( #1038942=note: print w/replies, xml ) Need Help??

in reply to how to use two dimensional array?

You may find this syntax for convenient.
use strict; use warnings; my @array = ( [1,2], [7,5], [4,4], [2,2], [0,7], [3,4], [8,9], [3,6], [5,7], [7,2], ); foreach my $pair (@array) { my ($x, $y) = @$pair; print "$x $y \n"; }

Replies are listed 'Best First'.
Re^2: how to use two dimensional array?
by hbm (Hermit) on Jun 14, 2013 at 11:52 UTC

    One of my favorite tidbits of the language - instead of your for loop:

    print "@$_\n" for @array;
      Very clever way of getting the same output, but I do not think it answers the original question. Also note your dependence om the default value of the special variable $LIST_SEPARATOR ($").

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038942]
[Discipulus]: ah no newest nodes! ask something
[beech]: why is my butt itchy
Discipulus many countries without bidet.. is a big problem!
[beech]: who told you i call my butt france?
Discipulus ??
beech waves a white flag -- no detectible causes of itch

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2016-12-09 09:46 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (150 votes). Check out past polls.