CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
A suggestion on how to work on a table

 



angeloulivieri
Novice

Jul 15, 2013, 10:46 AM

Post #1 of 3 (1034 views)
A suggestion on how to work on a table Can't Post

Hi all,
I've a large table of data about organisms from which I should access data to do statistics. The table can change and I have to easily change the code accordingly.
Different subroutines will access this table in different ways. So

I thought to load all the table in an array A[N][M]
and keep a PERL variable for each of the columns such that if I have to access a field $fieldA I can simply access A[x][fieldA].

Of course I have to set, for each field variable, the corresponding index number: $fieldA=0, $fieldB=1,..,$fieldM=M

If I have to add a column I have simply to change the correspoding index.

Do you think this is a good idea? Or something better is there?

Bye all!


BillKSmith
Veteran

Jul 15, 2013, 11:25 AM

Post #2 of 3 (1032 views)
Re: [angeloulivieri] A suggestion on how to work on a table [In reply to] Can't Post

Your approach would be ideal in languages which do not have hashes. In perl, I would prefer to use an array of hashes (refer: perldoc perldsc). Use your scheme only if the redundant storage of the field names requires excessive memory.
Good Luck,
Bill


angeloulivieri
Novice

Jul 16, 2013, 6:58 AM

Post #3 of 3 (1016 views)
Re: [BillKSmith] A suggestion on how to work on a table [In reply to] Can't Post

Ok.. you ansewer is nice.
I'll try to do it

Thanks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives