last -wi | grep \"Feb 22\" | head -10 >signinhw10 Use the format in this file fo
ID: 3813201 • Letter: L
Question
last -wi | grep "Feb 22" | head -10 >signinhw10
Use the format in this file for problem.
lab9c2.pl:
Problem:
• Use lab9c2.pl and the code fragment that follows it as the basis to write a perl script, hw10a.pl, to compute and print the number of the class B IP addresses
• Here is how the program would be executed. The output from my program is also given. To improve clarity, I have deleted a couple of warnings I got.
$ ./hw10a.pl signinhw10
Number of Class B addresses is 2
fs264sp170224Gsp-cfsics last -wi I grep Feb 22 I head. 10 >signinhw10 fs264 sp17022 4Gsp-cfsics cat signinhw10 cs311sp 170106 pts/4 104.200.153.92 Wed Feb 22 23:47 02:51 (03:04) 174. 53.245.117 Wed Feb 22 23: 33 00 16 (00 42) cs325 170128 pts/3 cs325sp 1718 pts/5 66. 41.183.50 Wed Feb 22 23:02 23: 56 (00:53) 66.41.19.59 cs325 170129 pts/8 Wed Feb 22 22:58 01:30 (02:31) cs325 170129 pts/0 66. 41. 19.59 Wed Feb 22 22:47 01:09 (02:21) 66.41.183.50 cs325sp 1711 pts/5 Wed Feb 22 22:44 22:59 (00:14) cs311sp 170106 pts/9 73. 37.196.191. Wed Feb 22 22:24 00 44 (02:20) 209. 63 158.124 Wed Feb 22 22:19 00 46 (02:27) cs325 170132 pts/7 174. 53.245. 117 Wed Feb 22 22:15 23:33 01:17) cs325 170128 pts/3 69.180. 158. 120 Wed Feb 22 22:02 22 38 (00 35) cs325 sp1723 pts/8Explanation / Answer
Question is not much clear... but based on my understanding, I have added the code for printing out the class B IP address.
#!/usr/bin/perl
use strict;
use warnings;
my $first_octet_num = "1";
my $ip_address;
foreach (1..254) {
foreach (1..255) {
if ($_ <= 254) {
$ip_address = join ('.', 192,168,$first_octet_num,$_);
print "$ip_address ";
} else
{ $first_octet_num++; }
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.