Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/perl -w
- #ECE 2524 Homework 3 Problem 3 Kevin Burns
- #Title: SERVER_REPORT
- use strict;
- #print the first 2 lines
- print "host accessing server\t: ipaddress\t: accesses : bytes transferred\n---------------------------------------------------------------------------\n";
- #Variables
- my ($host, $ip, $acc, $byte, $line, $i, ,$temp, %rows,@temp, @data);#@data will be the input of @rows
- #reading in from logfile and filling hash table with data
- while($line = <>) #splitting logfile into lines
- {
- chomp $line; #grabs the line
- @data = split (' ',$line); #parses the line
- $ip = $data[0];
- $rows{$ip} = [ @data ]; #fills 2d hash with ip as key
- }
- #display them as a format
- while(my ($key, @temp) = each(%rows))
- {
- format STDOUT =
- @H@<<<<<<<<<<<<<<<<<<<<<< : @<<<<<<<<<<<< : @>>>>>>> : @>>>>>>>>>>>>>>>>
- @H$temp[1],$key,$acc,$temp[2]
- @H.
- }
- $host = "a0028.esada.mns.net";
- $ip = "123.13.123.98";
- $acc = "23";
- write;
- #remember to add in a standard error report if too many or too few command line arguements are given exit gracefully
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement