diff --git a/Tools/perl/challenge12_final.pl b/Tools/perl/challenge12_final.pl new file mode 100644 index 00000000..5f78e163 --- /dev/null +++ b/Tools/perl/challenge12_final.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w +use strict; + + +our $data; +print "Please enter the file name:\n"; +my $file = <>; +chomp $file; + + if ($file ne "sta_log.txt") + { + print "File not found.\n"; + } + + else + { + + open(FH, $file) or die("File $file not found"); + + while(my $String = ) + { + + if($String =~ m/Computed maximum clock frequency (.*?)Hz/) + { + our $var = $1; #temp. + our ($fin) = $var =~ m/(\d+\.\d+)/; #magnitude + print "The computed maximum clock frequency is $var Hz\n"; + our $order = substr($var, -1); #exponential power + + if ($order eq "K") + { + my $opt = $fin * 1e-6; + print ("The computed maximum clock frequency in giga hertz is $opt G Hz\n"); + } + + if ($order eq "M") + { + my $opt = $fin * 1e-3; + print ("The computed maximum clock frequency in giga hertz is $opt G Hz\n"); + } + + if ($order eq "G") + { + my $opt = $fin; + print ("The computed maximum clock frequency in giga hertz is $opt G Hz\n"); + } + + if ($order eq "T") + { + my $opt = $fin * 1e3; + print ("The computed maximum clock frequency in giga hertz is $opt G Hz\n"); + } + } + + else + { + print "Computed maximum clock frequency isn't avaiable in the report.\n"; + } + } + + close(FH); + + } diff --git a/Tools/perl/challenge_1_2.pl b/Tools/perl/challenge_1_2.pl new file mode 100644 index 00000000..56db47dd --- /dev/null +++ b/Tools/perl/challenge_1_2.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w +use strict; + +our $data; +my $filename = "timig_rpt.txt"; +open(my $fh, '<', $filename) or die "Could not open file '$filename' $!"; + while (my $row = <$fh>) { + $data = $row; + } + +#print "$data\n"; +#print "The report has been extracted to a variable.\n"; + +our $freq; +if ($data =~ /Computed maximum clock frequency/) { + $freq = $data =~ /Computed maximum clock frequency(.*)hz/; + print "The Computed maximum clock frequency is: $freq\n";} +else { + print "Computed maximum clock frequency isn't avaiable in the report.\n";} +