Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Iterating over Blocks of 2-Dim Array

by BrowserUk (Patriarch)
on Apr 01, 2004 at 03:58 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found