Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Fun with two-dimensional arrays

by suaveant (Parson)
on Aug 09, 2001 at 21:00 UTC ( #103499=note: print w/replies, xml ) Need Help??


in reply to Fun with two-dimensional arrays

I would say do it the C way... (ish)
for my $x (0..21) { for my $y (0..79) { do_stuff($vscr[$x][$y]); } }
It works, and you always know your coordinates... you might want to define 21 and 79 as variables at the top of the program, though... in case screen size changes... or do
for my $x (0..$#vscr) { for my $y (0..$#{$vscr[$x]}) { do_stuff($vscr[$x][$y]); } }

                - Ant
                - Some of my best work - Fish Dinner

Replies are listed 'Best First'.
Re(2): Fun with two-dimensional arrays
by FoxtrotUniform (Prior) on Aug 09, 2001 at 21:07 UTC

    The problem with this is that you might well have more than 80 columns in any given row, as text gets written to that row (but not yet wrapped; text wrapping or trucation gets done later on).

      Well, the second method accounts for that... the 0..$#{$vscr[$x]} gives you 0 thru the length of that row...

      or you could set the width of a row to be arbitrarily long... like 500 chars... and just keep reading till one of them was undef (assuming good coords had a space instead of undef...

                      - Ant
                      - Some of my best work - Fish Dinner

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://103499]
help
Chatterbox?
[Lady_Aleena]: Corion, I knew that, I was just giving Discipulus a hard time.
choroba likes the story at the end of the node
[choroba]: reminds me of the days at the bank
[Corion]: Lady_Aleena: Hehe ;-D
[Lady_Aleena]: Corion, it was PerlMonks who kept pushing me to get Linux, so now I know some of the commands to use in word play.
[Corion]: Lady_Aleena: :-D
[Lady_Aleena]: Corion, so do you think the gods would be open to taking over Cookies should I disappear for too long a time?

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-04-26 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (471 votes). Check out past polls.