Question

Please use lab10d.pl introduced in Lab 10 as a template to write a perl script, hw10a.pl,...

Please use lab10d.pl introduced in Lab 10 as a template to write a perl script, hw10a.pl, to compute the number of the IP addresses that begin with “24” in the data file created as follow, loginfile4hw10; $ last -i | grep "Mar 27" | head -10 > loginfile4hw10 $ cat loginfile4hw10 cfs264sp pts/7 24.118.93.235 Wed Mar 27 23:34 - 23:42 (00:08) cfs264sp pts/7 24.118.93.235 Wed Mar 27 23:14 - 23:33 (00:19) cfs264sp pts/2 73.242.55.42 Wed Mar 27 22:50 - 01:24 (02:34) cfs264sp pts/0 24.245.4.209 Wed Mar 27 22:20 - 23:58 (01:38) cfs264sp pts/0 73.88.53.3 Wed Mar 27 21:39 - 22:05 (00:26) cfs264sp pts/8 24.131.165.45 Wed Mar 27 21:09 - 23:49 (02:40) cfs264sp pts/7 73.37.185.134 Wed Mar 27 20:59 - 21:55 (00:56) cfs264sp pts/2 71.195.24.153 Wed Mar 27 20:15 - 21:42 (01:27) cfs264sp pts/7 68.46.23.158 Wed Mar 27 19:48 - 20:14 (00:26) cfs264sp pts/7 65.128.58.29 Wed Mar 27 19:18 - 19:39 (00:21)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

NOTE: I have completed answer for your question. Please check and let me know if you have any queries. I will get back to you within 24 hours. Thanks for your patience.

Code:

#!/usr/bin/perl

use strict;

use warnings;

# setting the filename to be read

my $fname = 'loginfile4hw10';

# opening the file in read mode

open(FH, $fname) or die "$fname cannot be opened: $!";

# reading each line from file

while (my $line = <FH>){

# removing newline from each line

chomp $line;

# checking if the IP starts with 24

if ($line =~ /.* .* 24\./){

print $line, "\n";

}

}

# closing the file

close(FH);

Code output screenshot:

Add a comment
Answer #2

NOTE: I have completed answer for your question. Please check and let me know if you have any queries. I will get back to you within 24 hours. Thanks for your patience.

Code:

#!/usr/bin/perl

use strict;

use warnings;

# setting the filename to be read

my $fname = 'loginfile4hw10';

# opening the file in read mode

open(FH, $fname) or die "$fname cannot be opened: $!";

# reading each line from file

while (my $line = <FH>){

# removing newline from each line

chomp $line;

# checking if the IP starts with 24

if ($line =~ /.* .* 24\./){

print $line, "\n";

}

}

# closing the file

close(FH);

Code output screenshot:

Add a comment
Know the answer?
Add Answer to:
Please use lab10d.pl introduced in Lab 10 as a template to write a perl script, hw10a.pl,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please write an awk script to display from the sixth to ninth records in “loginfile.” Please...

    please write an awk script to display from the sixth to ninth records in “loginfile.” Please test your script to make sure the script displays the following information: ics325fa1531 pts/5 10.10.76.114 Thu Oct 15 19:38 - 19:38 (00:00) ics325fa1531 pts/4 10.10.76.114 Thu Oct 15 19:37 - 19:39 (00:02) ics325fa1524 pts/3 10.10.76.100 Thu Oct 15 19:25 - 21:50 (02:24) ics325fa1524 pts/3 10.10.76.100 Thu Oct 15 19:22 - 19:25 (00:03)

  • For Questions 1-2, use table below. It is data for two stocks over 30 days (it...

    For Questions 1-2, use table below. It is data for two stocks over 30 days (it is sample data). Day High stock Sky stock Day High stock Sky stock 1 27 60 16 43 39 2 33 57 17 45 37 3 34 56 18 46 35 4 35 55 19 47 34 5 36 54 20 47 32 6 37 51 21 48 29 7 38 50 22 50 26 8 38 47 23 50 26 9 39 47...

  • please determine the output in a simple form #include <stdio.h> 2 3 //Item 02 4 int...

    please determine the output in a simple form #include <stdio.h> 2 3 //Item 02 4 int main() 5 6 7 8 9 10 int i for( i = 0 ; i < 5 ; i++ ) ifo 12 13 14 15 16 17 18 19 20 21 printf("A" printf("B"); if i > 2 ) printf("C"); 23 24 25 26 27 28 29 30 31 32 if( i 3) printf( "D") if>4) printf("E 34 35 36 37 38 39 40 41...

  • Please show how you did this in excel. :13-19 Every home football game for the past...

    Please show how you did this in excel. :13-19 Every home football game for the past eight years at Eastern State University has been sold out. The revenues from ticket sales are significant, but the sale of food, beverages, and souvenirs has contrib- uted greatly to the overall profitability of the football program. One particular souvenir is the football pro- gram for each game. The number of programs sold at each game is described by the following probabil- ity distribution:...

  • Game   Point_Differential   Assists   Rebounds   Turnovers   Personal_Fouls 1   15   15   38   11   9 2   36   20   43 &

    Game   Point_Differential   Assists   Rebounds   Turnovers   Personal_Fouls 1   15   15   38   11   9 2   36   20   43   8   13 3   16   21   29   7   13 4   45   22   46   11   11 5   12   11   40   7   22 6   -10   10   31   13   26 7   11   19   45   11   7 8   12   16   32   16   14 9   3   16   27   18   15 10   19   9   34   17   17 11   40   16   41   9   17 12   44   12   29   9   22 13   16  ...

  • Graph the mean winning margins for years 2005 - 2007 for women's NCAA Basketball tournaments. Is...

    Graph the mean winning margins for years 2005 - 2007 for women's NCAA Basketball tournaments. Is there a trend over time? 2005 Winning Margin 34 3 1 8 26 17 22 32 35 3 22 10 22 31 3 21 51 12 2 20 5 25 10 41 32 16 23 10 33 48 12 37 2006 Winning Margin 24 12 13 21 4 5 15 48 23 17 5 19 24 18 10 41 69 2 10 19 6...

  • Magic Square question for Python

    You have this solution in Java, I am interested in this same solution for Python.One interesting application of two-dimensional arrays is magic squares. A magic square is a square matrix in which the sum of every row, every column, and bothdiagonals is the same. Magic squares have been studied for many years, and there are some particularly famous magic squares. In this exercise you will write code todetermine whether a square is magic.You should find that the first, second, and...

  • Task 2 Write a shell script program call cal3.sh to do the following. 1. Print the...

    Task 2 Write a shell script program call cal3.sh to do the following. 1. Print the output "you must provide at least one month" when there is no argument 2. Print the calendar with specified month matching the argument when there is one argument $ ./cal3.sh 1 January 2016 Su Mo Tu We Th Fr Sa 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 25 26 27...

  • Pls help on filling out Tritraion of a Polyprotic acid chart Data from lab Titration #1...

    Pls help on filling out Tritraion of a Polyprotic acid chart Data from lab Titration #1 Titration #2 Titration #3 mL base added pH mL base added pH mL base added pH 1 0.7 1 0.7 1 0.7 2 1.1 2 1 2 0.9 3 1.5 3 1.4 3 1.3 4 1.7 4 1.6 4 1.5 5 1.9 5 1.8 5 1.7 6 2 6 2.1 6 2 7 2.2 7 2.2 7 2.2 8 2.4 8 2.3 8 2.2...

  • In a psychiatric study of families of schizophrenic children two Rorshach scores of the mothers (M, and M,)

    III. In a psychiatric study of families of schizophrenic children two Rorshach scores of the mothers (M, and M,) and fathers ( F, F,) were of particular import. The observed values of these scores for parents of nl=10 psychotic adolescents and n2=10 normal control children of similar age and economic status are given below:SchizophreniacontrolM1M2F1F2M1M2F1F230352533201526252141152111318192732253472118353431362115242220371421151117132338192513122015282726302213221932422937539122636273321132019293524321412108 Analyze this data.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT