Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
open (IN1s,"$ARGV[0].sum"); open (IN2s,"$ARGV[1].sum"); open (XLOUT,">pt.forxl"); open (ASTONLY,">ast.only"); open (PTONLY,">pt.only"); @in1s = <IN1s>; @in2s = <IN2s>; %AstContent = (); $ln = 0; while ($in1s[$ln] ne "") { chop ($in1s[$ln]); @in1sal = split(/\s+/,$in1s[$ln]); $astlength = @in1sal; $astlast = $astlength - 1; for ($i = 0; $i <= 3; $i++) { $AstStartEndWithClocks = join (" ",$AstStartEndWithClocks,$in1 +sal[$i]); } for ($i = 7; $i <= $astlast; $i++) { $AstMasterList = join (" ",$AstMasterList,$in1sal[$i]); } $AstContent{$AstStartEndWithClocks,$AstMasterList} = @in1sal; # # I know the above hash table is wrong, but I don't # know how to create a table with 2 keys. In short, # take the current list (@in1sal) and assign 2 keys # to it. # $AstStartEndWithClocks = (); # undef in case the # same pattern of 4 # words comes up again $AstMasterList = (); # undef this because # its length can change # from one line to the # next... undef (@in1sal); $ln++; } %PTContent = (); $ln = 0; while ($in2s[$ln] ne "") { chop ($in2s[$ln]); @in2sal = split(/\s+/,$in2s[$ln]); $ptlength = @in2sal; $ptlast = $ptlength - 1; for ($i = 0; $i <= 3; $i++) { $PTStartEndWithClocks = join (" ",$PTStartEndWithClocks,$in2sa +l[$i]); } for ($i = 7; $i <= $ptlast; $i++) { $PTMasterList = join (" ",$PTMasterList,$in2sal[$i]); } $PTContent{$PTStartEndWithClocks,$PTMasterList} = @in2sal; # # Same deal as above: I know this is wrong but I # don't know how to assign 2 keys to the current # list (@in2sal)... # $PTStartEndWithClocks = (); $PTMasterList = (); undef (@in2sal); $ln++; } # Parse each hash table (AstContent and PTContent)--when # AstStartEndWithClocks and PTStartEndWithClocks match, # print the result to file XLOUT. # Now, if there was an # AstStartEndWithClocks/PTStartEndWithClocks match, check # to see of $AstMasterList and $PTMasterList match. If they # do NOT, print the line to the screen. # If AstContent's AstStartEndWithClocks cannot be matched # in PTContent, write the line to the file ASTONLY. # If PTContent's PTStartEndWithClocks cannot be matched in # AstContent, write the line to the file PTONLY.
janitored by ybiC: Balanced <readmore> tags around longish codeblock, to avoid/reduce vertical scrolling
|
|---|