Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. use Data::Dumper qw(Dumper);
  2. use strict;
  3. use warnings;
  4. die "Usage: $0 FILENAMEs" if not @ARGV;
  5. my $ni= 10;
  6. my $fi=10;
  7. my $flag =0;
  8. my $ni1=10;
  9. my $fi1 =10;
  10. foreach my $file (@ARGV) {
  11. open my $fh,"<$file.a" or die;
  12. while (my $line = <$fh>) {
  13. if ($line =~ /count/) {
  14. my @ores = split /:/, $line, 2;
  15. if( $file eq "k4" and $flag ==1)
  16. {
  17. $ni1= $ores[1];
  18. }
  19. else
  20. {
  21. $flag=$flag+1;
  22. $ni= $ores[1];
  23. print "NI--", $ni;
  24. }
  25. }
  26. }
  27. close $fh;
  28. $flag=0;
  29. open $fh,"<$file.b" or die;
  30. while (my $line = <$fh>) {
  31. if ($line =~ /count/) {
  32. my @ores = split /:/, $line, 2;
  33. if( $file eq "k4" and $flag ==1)
  34. {
  35. $flag = $flag+1;
  36. $fi1= $ores[1];
  37. }
  38. else
  39. {
  40. $fi=$ores[1];
  41. print "FI--", $fi;
  42. }
  43. }
  44. }
  45. close $fh;
  46. open($fh, ">>$file.log") or die "Could not open file '$file'.log $!";
  47. if($file eq "k4")
  48. {
  49. print $fh " First Instance of K4 n-----------------------------------n";
  50. }
  51. if( $ni > $fi)
  52. {
  53. print $fh " FI: ", $fi;
  54. print $fh " NI: ", $ni;
  55. print $fh " NI is more than FI by: ", $ni-$fi;
  56. }
  57. else
  58. {
  59. print $fh " FI: ", $fi;
  60. print $fh " NI: ", $ni;
  61. print $fh " FI is more than NI by: ",$fi-$ni;
  62. }
  63. if( $file eq "k4")
  64. {
  65. print $fh "n Second instance of K4";
  66. if($ni1 > $fi1)
  67. {
  68. print $fh " FI: ", $fi1;
  69. print $fh "n NI: ", $ni1;
  70. print $fh " NI is more than FI by: ", $ni1-$fi1;
  71. }
  72. else
  73. {
  74. print $fh " FI: ", $fi1;
  75. print $fh "n NI: ", $ni1;
  76. print $fh " FI is more than NI by: ",$fi1-$ni1;
  77. }
  78. }
  79. }
  80.  
  81. Loops count : 12345
  82.  
  83. Roots count : 45679
  84.  
  85. FI: 45679
  86. NI: 12345
  87. FI is more than NI by: 33334
  88.  
  89. $wc -l file1.log
  90. 2 file1.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement