Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Data::Dumper qw(Dumper);
- use strict;
- use warnings;
- die "Usage: $0 FILENAMEs" if not @ARGV;
- my $ni= 10;
- my $fi=10;
- my $flag =0;
- my $ni1=10;
- my $fi1 =10;
- foreach my $file (@ARGV) {
- open my $fh,"<$file.a" or die;
- while (my $line = <$fh>) {
- if ($line =~ /count/) {
- my @ores = split /:/, $line, 2;
- if( $file eq "k4" and $flag ==1)
- {
- $ni1= $ores[1];
- }
- else
- {
- $flag=$flag+1;
- $ni= $ores[1];
- print "NI--", $ni;
- }
- }
- }
- close $fh;
- $flag=0;
- open $fh,"<$file.b" or die;
- while (my $line = <$fh>) {
- if ($line =~ /count/) {
- my @ores = split /:/, $line, 2;
- if( $file eq "k4" and $flag ==1)
- {
- $flag = $flag+1;
- $fi1= $ores[1];
- }
- else
- {
- $fi=$ores[1];
- print "FI--", $fi;
- }
- }
- }
- close $fh;
- open($fh, ">>$file.log") or die "Could not open file '$file'.log $!";
- if($file eq "k4")
- {
- print $fh " First Instance of K4 n-----------------------------------n";
- }
- if( $ni > $fi)
- {
- print $fh " FI: ", $fi;
- print $fh " NI: ", $ni;
- print $fh " NI is more than FI by: ", $ni-$fi;
- }
- else
- {
- print $fh " FI: ", $fi;
- print $fh " NI: ", $ni;
- print $fh " FI is more than NI by: ",$fi-$ni;
- }
- if( $file eq "k4")
- {
- print $fh "n Second instance of K4";
- if($ni1 > $fi1)
- {
- print $fh " FI: ", $fi1;
- print $fh "n NI: ", $ni1;
- print $fh " NI is more than FI by: ", $ni1-$fi1;
- }
- else
- {
- print $fh " FI: ", $fi1;
- print $fh "n NI: ", $ni1;
- print $fh " FI is more than NI by: ",$fi1-$ni1;
- }
- }
- }
- Loops count : 12345
- Roots count : 45679
- FI: 45679
- NI: 12345
- FI is more than NI by: 33334
- $wc -l file1.log
- 2 file1.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement