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: Beginner: A file parsing and 2D array/matrix problem.: Edit Log



rushadrena
Novice

Aug 25, 2012, 8:32 AM


Views: 7581
A file parsing and 2D array/matrix problem.

 I am stuck with this complicated problem. I have a list

** LIST**
[code]
substrate[s]: 3649
product[s]: 3419 3648
substrate[s]: 3645
product[s]: 3647
substrate[s]: 3659
product[s]: 3647
substrate[s]: 3675
product[s]: 3674
substrate[s]: 3674
product[s]: 3490 3489
substrate[s]: 3489
product[s]: 3490
substrate[s]: 3490
product[s]: 3485
substrate[s]: 3485
product[s]: 3486
substrate[s]: 3486
product[s]: 3488
substrate[s]: 3488
product[s]: 3487
substrate[s]: 3487
product[s]: 3877
substrate[s]: 3877
product[s]: 3419
substrate[s]: 3182
product[s]: 1875
substrate[s]: 2809
product[s]: 3182
substrate[s]: 3186
product[s]: 2809 [/code]


Now I have a superlist each of substrate & product as:-

**SUPERLIST_SUBSTRATE**
[code]
substrate[s]: 3649
substrate[s]: 3645
substrate[s]: 3659
substrate[s]: 3675
substrate[s]: 3674
substrate[s]: 3489
substrate[s]: 3490
substrate[s]: 3485
substrate[s]: 3486
substrate[s]: 3488
substrate[s]: 3487
substrate[s]: 3877
substrate[s]: 3182
substrate[s]: 2809
substrate[s]: 3186
substrate[s]: 3675
substrate[s]: 3492
substrate[s]: 3314
substrate[s]: 3006
substrate[s]: 3049[/code]


**SUPERLIST_PRODUCT**
[code]
product[s]: 3419
product[s]: 3648
product[s]: 3489
product[s]: 3647
product[s]: 3647
product[s]: 3674
product[s]: 3490
product[s]: 3490
product[s]: 3485
product[s]: 3486
product[s]: 3488
product[s]: 3487
product[s]: 3877
product[s]: 3419
product[s]: 1875
product[s]: 3182
product[s]: 2809
product[s]: 3492
product[s]: 3186
product[s]: 3492
product[s]: 1825
product[s]: 2543 [/code]


The superlist_product and superlist_substrate will encompass all the possible substrates & products in LIST. ie. substrate(LIST) is a subset of superlist_substrate and similarly for product(LIST). Now i want to create a SUPERARRAY as superlist_substrate(rows) X superlist_product(columns). Now parse the LIST for each substrate id one by one insert a "1" for each product id in the SUPERARRAY. For example consider first two lines of LIST

substrates: 3649

products: 3419 3648
So for substrate id 3649 ,the row id=3649 will be selected from SUPERARRAY and a "1" will be inserted at column ids 3419 & 3648 of the SUPERARRAY. And so on for the entire LIST.Basically SUPERARRAY will be a matrix.


(This post was edited by rushadrena on Aug 25, 2012, 8:34 AM)


Edit Log:
Post edited by rushadrena (Novice) on Aug 25, 2012, 8:33 AM
Post edited by rushadrena (Novice) on Aug 25, 2012, 8:34 AM


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

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