Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Matrix Declaration / Data Structure Syntax Question

by kcott (Abbot)
on Mar 10, 2013 at 00:49 UTC ( #1022634=note: print w/ replies, xml ) Need Help??


in reply to Matrix Declaration / Data Structure Syntax Question

G'day oxirane,

Welcome to the monastery.

When presented with a complex data structure, you may find Data::Dumper to be a useful tool.

Here's a simplified version of your matrix:

$ perl -Mstrict -Mwarnings -e ' use Data::Dumper; my @matrix; for my $i (0 .. 1) { for my $j (0 .. 1) { $matrix[$i][$j]{row} = $i; $matrix[$i][$j]{col} = $j; } } print Dumper \@matrix; ' $VAR1 = [ [ { 'col' => 0, 'row' => 0 }, { 'col' => 1, 'row' => 0 } ], [ { 'col' => 0, 'row' => 1 }, { 'col' => 1, 'row' => 1 } ] ];

-- Ken


Comment on Re: Matrix Declaration / Data Structure Syntax Question
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022634]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-12-27 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls