in reply to Re^6: constructing a tree from csv file
in thread constructing a tree from csv file

Did you use the [download] link to get the code? Tab characters are used in the DATA section, plain spaces would break the programme.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^8: constructing a tree from csv file
by zing (Beadle) on Nov 11, 2013 at 11:09 UTC
    Ohh yeah. BTW I must say, I leant a lot by simply reading through your code. Thanks it was lucidly written.
Re^8: constructing a tree from csv file
by zing (Beadle) on Nov 19, 2013 at 05:05 UTC
    Choroba I did it but again the same error-
    Use of uninitialized value in print at final.pl line 71, <DATA> line 7 +. , ,3: M143<-M10<-Q = P, Use of uninitialized value in print at final.pl line 71, <DATA> line 7 +. , ,0: M420<-M143<-M10<-Q = P, Use of uninitialized value in print at final.pl line 71, <DATA> line 7 +. , L,: M407<-M143<-M10<-Q = P, Use of uninitialized value in print at final.pl line 71, <DATA> line 7 +. , 0: M10<-Q = P, Use of uninitialized value in print at final.pl line 71, <DATA> line 7 +. , ,1: M421<-M143<-M10<-Q = P, Use of uninitialized value in print at final.pl line 71, <DATA> line 7 +. , L,: M406<-M143<-M10<-Q = P,
    LINE 71 being   print " = ", $path_string, ', ', $group{$path_string};
      You are not using tabs to separate the columns.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^8: constructing a tree from csv file
by zing (Beadle) on Nov 19, 2013 at 05:36 UTC
    Choroba i modified your code for my requirements and now %group hash has 40 keys, and __DATA__ has 345 lines. The problem is that the code hangs and gets killed after sometime without any output. CPU usage going to 100%,system hang. Whereas if I reduce the __DATA__ lines to 300 lines only, then it runs . Why is it so. My system has 64Gigs ram, and hexacore.
      There is a cycle in your "tree". Trees should not contain cycles.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Thanks choroba. How can I stop the code from going beyond the parent Q. i.e. once it has reached Q it should stop checking further.  M420<-M143<-M10<-Q It should stop here and not go further beyond Q. Thanks
        I tried using "next"
        while ($parent = $tree{$parent}{parent}[0]) { if ( $parent eq 'Q' ) {next;}
        But its still getting hanged !!!!
Re^8: constructing a tree from csv file
by zing (Beadle) on Nov 19, 2013 at 06:31 UTC
    Choroba the reason for uninitliazed error that Im getting is because my group hash doesnt have relations which are more than length 3. As you can see below. E.P.E.E is 4 relations. But thats alright as I dont want to have relations which are more than three. But could this also be the reaso n behind the program getting hanged when run on __DATA__ more than 300 lines:-
    Use of uninitialized value in print at checking.pl line 71, <DATA> lin +e 338. M61: M61<-M7<-M28<-M6<-Q = E.P.E.E, Use of uninitialized value in print at checking.pl line 71, <DATA> lin +e 338. M196: M196<-M53<-M7<-M28<-M6<-Q = E.P.E.Pl.E,
      To avoid the warnings, just do not print anything if the relation is not defined:
      print " = ", $path_string, ', ', $group{$path_string} // q();
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Choroba what if I dont want those lines which dont have a group (from the group hash) to be "even" printed ? For example a line which has relation : E.E.E.P.Pl doesnt have a corresponding key-value pair in the group hash, so I would like this complete row to not even get printed. I guess something has to be added in this line   print " , ", $path_string, ', ', $group{$path_string};