Skip to content

Challenge 1 & 2 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Tools/perl/challenge12_final.pl
Original file line number Diff line number Diff line change
@@ -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 = <FH>)
{

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);

}
20 changes: 20 additions & 0 deletions Tools/perl/challenge_1_2.pl
Original file line number Diff line number Diff line change
@@ -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";}