Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: A complicated file parsing and 2D array/matrix problem.

by zing (Beadle)
on Sep 04, 2012 at 07:36 UTC ( #991564=note: print w/ replies, xml ) Need Help??


in reply to Re^3: A complicated file parsing and 2D array/matrix problem.
in thread A file parsing and 2D array/matrix problem.

Kenosis, Theres a small problem. I tried to check whether the code is giving desired output,but it isnt giving the complete result.Consider my

LIST.txt

substrate[s]: 1 2 product[s]: 3 substrate[s]: 6 9 product[s]: 8 10 substrate[s]: 3 product[s]: 6 substrate[s]: 9 product[s]: 5 substrate[s]: 5 product[s]: 2 substrate[s]: 3 product[s]: 9 substrate[s]: 8 product[s]: 9 substrate[s]: 8 product[s]: 1 substrate[s]: 7 product[s]: 11 substrate[s]: 19 product[s]: 17 substrate[s]: 14 product[s]: 13 substrate[s]: 14 product[s]: 11 substrate[s]: 18 product[s]: 19 substrate[s]: 7 14 product[s]: 15 substrate[s]: 7 16 product[s]: 7 17 substrate[s]: 5 product[s]: 6 substrate[s]: 18 15 product[s]: 7 substrate[s]: 7 8 product[s]: 8 18 substrate[s]: 6 product[s]: 9 substrate[s]: 11 product[s]: 12
SUPERLIST_SUBSTRATE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
SUPERLIST_PRODUCT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
********OUTPUT********
p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 s1 . . 1 . . . . . . . . . . . . . . . . s2 . . . . . . . . . . . . . . . . . . . s3 . . . . . 1 . . 1 . . . . . . . . . . s4 . . . . . . . . . . . . . . . . . . . s5 . 1 . . . 1 . . . . . . . . . . . . . s6 . . . . . . . 1 1 1 . . . . . . . . . s7 . . . . . . 1 1 . . 1 . . . 1 . 1 1 . s8 1 . . . . . . . 1 . . . . . . . . . . s9 . . . . 1 . . . . . . . . . . . . . . s10 . . . . . . . . . . . . . . . . . . . s11 . . . . . . . . . . . 1 . . . . . . . s12 . . . . . . . . . . . . . . . . . . . s13 . . . . . . . . . . . . . . . . . . . s14 . . . . . . . . . . 1 . 1 . . . . . . s15 . . . . . . . . . . . . . . . . . . . s16 . . . . . . . . . . . . . . . . . . . s17 . . . . . . . . . . . . . . . . . . . s18 . . . . . . 1 . . . . . . . . . . . 1 s19 . . . . . . . . . . . . . . . . 1 . .
Consider first two lines of LIST.txt -
substrate[s]: 1 2 product[s]: 3
. Then there is a "1" s1-p3, but there isn;t a "1" for s2-p3. ################DESIRED OUTPUT -- Places marked with "X" need to be "1" #################
p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 s1 . . 1 . . . . . . . . . . . . . . . . s2 . . X . . . . . . . . . . . . . . . . s3 . . . . . 1 . . 1 . . . . . . . . . . s4 . . . . . . . . . . . . . . . . . . . s5 . 1 . . . 1 . . . . . . . . . . . . . s6 . . . . . . . 1 1 1 . . . . . . . . . s7 . . . . . . 1 1 . . 1 . . . 1 . 1 1 . s8 1 . . . . . . X 1 X . . . . . . . X . s9 . . . . 1 . . . . . . . . . . . . . . s10 . . . . . . . . . . . . . . . . . . . s11 . . . . . . . . . . . 1 . . . . . . . s12 . . . . . . . . . . . . . . . . . . . s13 . . . . . . . . . . . . . . . . . . . s14 . . . . . . . . . . 1 . 1 . X . . . . s15 . . . . . . X . . . . . . . . . . . . s16 . . . . . . X . . . . . . . . . X . . s17 . . . . . . . . . . . . . . . . . . . s18 . . . . . . 1 . . . . . . . . . . . 1 s19 . . . . . . . . . . . . . . . . 1 . .


Comment on Re^4: A complicated file parsing and 2D array/matrix problem.
Select or Download Code
Replies are listed 'Best First'.
Re^5: A complicated file parsing and 2D array/matrix problem.
by Kenosis (Priest) on Sep 05, 2012 at 14:59 UTC

    Hi, zing.

    Was this issue resolved? I noticed a new posting where a blank line in a file was mentioned...

      Kenosis it was resolved. Im facing another issue. I need to pick list.txt files one by one from each 5 subdirectories(d1,d2,d3,d4,d5) in the present directory. Here's the relevant snippet from the code
      #!/usr/bin/perl use strict; use warnings; use List::Util qw/ max /; open my $fh, "<", 'SUPERLIST_PRODUCT' or die $!; my $spr_prod = do {local $/; <$fh>}; close $fh or die $!; my @spr_prod = $spr_prod =~ /\d+/g; open $fh, "<", 'SUPERLIST_SUBSTRATE' or die $!; my $spr_substr = do {local $/; <$fh>}; close $fh or die $!; my @spr_substrate = $spr_substr =~ /\d+/g; my @matrix; my $path = '.'; # (current directory - '.') or path to data files my @file = qw/list.txt/;

        Am glad to hear that it's resolved.

        Since you're "facing another issue," it should be addressed in a new node created for it, so present and future PM browsers can benefit from the dialog.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2015-07-30 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls