Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: How to swap rows with columns?

by johngg (Canon)
on Oct 09, 2007 at 22:11 UTC ( #643816=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to swap rows with columns?
in thread How to swap rows with columns?

for my $y (0..(@in-1)) { for my $x (0..(@{$in[$y]}-1)) {

I'm puzzled as to why you do the subtractions to find the upper bound of the arrays rather than use the $#array that Perl provides.

for my $y ( 0 .. $#in ) { for my $x ( 0 .. $#{$in[$y]} ) {

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^4: How to swap rows with columns?
by snopal (Pilgrim) on Oct 10, 2007 at 02:14 UTC

    My original did, but the second loop definition was looking like line noise and I was demonstrating the practice to a novice. So I opted for the more verbose, and less obtuse example.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2020-11-25 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?