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

[MacPerl-WebCGI] 2 Basic loop question(?)



Hi all:

I'm a Perl beginner trying to do something with I guess is pathetically
basic but I haven't been able to work out.

I'm opening a tag delimited file which contains a data base (ie: 25 rows x
30 cols). In order to be able to refer to each 'cell' in the data base (ie:
$c7 = 3rd row, 7th column'), I'm doing:

open(INF,"data.txt") or die() ;
@datos = <INF>;
close(INF);
chomp(@datos );        #    ...then...:

$a = $datos[0];
$b = $datos[1];
$c = $datos[2];
$d = $datos[3];
.... (all the way to)...
$z = $datos[25];         #         !!!!, .... and then...:

($a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14,
$a15, $a16, $a17, $a18, $a19, $a20, $a21, $a22, $a23, $a24, $a25, $a26,
$a27, $a28, $a29, $a30) = split(/\t/,$a);
....(all the way to)...
($z1, $z2, $z3, $z4, $z5, $z6, $z7, $z8, $z9, $z10, $z11, $z12, $z13, $z14,
$z15, $z16, $z17, $z18, $z19, $z20, $z21, $z22, $z23, $z24, $z25, $z26,
$z27, $z28, $z29, $z30) = split(/\t/,$z);   # !!!!!!!!


Now, though clumsy, it *does* work, but I'm sure there's a more proper way
to do it using loops, aside from the fact that it wouldn't be very practical
to write for a 300 row x 300 column data sheet!

I've been trying to figure these loops out, but have "failed with all
success".

Can somebody *please* give me a hand with better alternatives, be them loops
or some kind of shortcut?


Thank you,


Riccardo Perotti




--
mailto:perotti@pobox.com



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