Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.08 KB | None | 0 0
  1. #! /usr/bin/perl -w
  2.  
  3. #ECE 2524 Homework 3 Problem 3 Kevin Burns
  4. #Title: SERVER_REPORT
  5.  
  6. use strict;
  7.  
  8.  
  9. #print the first 2 lines
  10. print "host accessing server\t: ipaddress\t: accesses : bytes transferred\n---------------------------------------------------------------------------\n";
  11.  
  12. #Variables
  13. my ($host, $ip, $acc, $byte, $line, $i, ,$temp, %rows,@temp, @data);#@data will be the input of @rows
  14.  
  15.  
  16. #reading in from logfile and filling hash table with data
  17. while($line = <>) #splitting logfile into lines
  18. {
  19.  chomp $line;                   #grabs the line
  20.  @data = split (' ',$line);     #parses the line
  21.  $ip = $data[0];
  22.  $rows{$ip} =  [ @data ];       #fills 2d hash with ip as key
  23. }
  24.  
  25.  
  26. #display them as a format
  27. while(my ($key, @temp) = each(%rows))
  28. {
  29.  format STDOUT =
  30. @<<<<<<<<<<<<<<<<<<<<<< : @<<<<<<<<<<<< : @>>>>>>> : @>>>>>>>>>>>>>>>>
  31. $temp[1],$key,$acc,$temp[2]
  32. .
  33. }
  34.  
  35. $host = "a0028.esada.mns.net";
  36. $ip = "123.13.123.98";
  37. $acc = "23";
  38. write;
  39.  
  40. #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