Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Iterating over Blocks of 2-Dim Array

by BrowserUk (Pope)
on Apr 01, 2004 at 03:58 UTC ( #341502=note: print w/ replies, xml ) Need Help??


in reply to Iterating over Blocks of 2-Dim Array

#! perl -slw use strict; use Data::Dumper; # create matrix # # [ # [ a, b, c, d ], # [ e, f, g, h ], # [ i, j, k, l ], # [ m, n, o, p ], # ] my $a = 'a'; my @a2d = map{ [ map{ $a++ } 1..4 ] } 1..4; #print Dumper \@a2d; for my $y ( 0, 2 ) { for my $x ( 0, 2 ) { print @{ $a2d[ $y ] }[ $x .. $x+1 ]; print @{ $a2d[ $y+1 ] }[ $x .. $x+1 ], $/; } } __END__ ab ef cd gh ij mn kl op

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail


Comment on Re: Iterating over Blocks of 2-Dim Array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2014-07-30 07:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls