[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Re: [MacPerl-WebCGI] Can you read a file "vertically"?



I'm resending this as it hasn't appeared on the list yet (after 4 days),
apologies if this creates duplicates
>Q: is there a way (and what is it) to end up with these three arrays:
>    @array1 = (do,fa,si)
>    @aray2 = (re,sol,de)
>    @array3 =(mi,la,me) ?
I think you're looking for a matrix

#! perl -w

#=========== declare includes =============

use strict;
use diagnostics-verbose;

#========== declare variables =============

my(@matrix);

#============= script body ================

 @matrix= ( ["do","fa","si"],
	    ["re","sol","de"],
	    ["mi","la","me"]
	    );

# You can reference the matrix by using its co-ordinates
# (remember arrays begin at 0 however

print $matrix [0][0], "\n";  #will print the top corner ('do')

print $matrix [2][2], "\n";  #will print the bottom corner ( 'me')
__END__

HTH

Robin

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org