Saturday 25 May 2013

STUCK W/ PERL SCRIPT

STUCK W/ PERL SCRIPT

I think it's better if I put the instruction first and show you my code. Can you help me out parts where I need to modify?
The program must check that: a) it is invoked with the appropriate number of arguments, and b) the values for the option argument are as described below, and c) that the net_usage_file argument is a readable file. The examples below clarify the valid invocations. In all other cases, the program must print a message to the standard output explaining to the user how the program should be invoked correctly, and exit.
File net_usage_file can have any arbitrary name. It must be a file of text with the following format: a. The first line contains names of fields. b. The first line is followed by an arbitrary number of other lines (including, possibly, zero lines). c. Each of the lines after the first must contain seven fields aligned as in the example below. The seven fields are: • Protocol: the protocol’s acronym; width: 10 characters; • Rx-ok: the number of correctly received units; width: 8 characters; • Rx-err: the number of units received with errors; width: 8 characters; • Rx-drp: the number of received units dropped; width: 8 characters; • Tx-ok: the number of correctly transmitted units; width: 8 characters; • Tx-err: the number of units transmitted with errors; width: 8 characters; • Tx-drp: the number of transmitted units dropped; width: 8 characters. d. The Protocol field is a string of characters. Acceptable characters include: lower case letters, upper case letters, and digits. The same string can appear only in one line. e. Every other field is a string of decimal digits. The following is an example of file net_usage_file: Protocol Rx-ok Rx-err Rx-drp Tx-ok Tx-err Tx-drp TCP 123000 12 20 64000 0 0 UDP 3225235 244 204 44333 2 0 IPv4 4800000 898 645 7812167 345 0
Your program can be invoked with option: -n. In this case, it must print the following: Protocols: … Example with the example net_usage_file given above: Command line: net_summary.pl -n net_usage_file Output: Protocols: TCP UDP IPv4 In the case in which file net_usage_file is empty, your program must instead only print: No protocols present
Your program can be invoked with option: –r. In this case, it must only print the following string: Total number of units received: Example with the example net_usage_file given above: Command line: net_summary.pl –r net_usage_file Output: Total number of units received: 8150258 In the case in which file net_usage_file is empty, your program must print: Total number of units received: 0
Your program can be invoked with option: –t. In this case, it must only print the following string:
Total number of units transmitted: Example with the example net_usage_file given above: Command line: net_summary.pl –t net_usage_file Output: Total number of units transmitted: 7920847 In the case in which file net_usage_file is empty, your program must print: Total number of units transmitted: 0
Your program can be invoked with option: –p . In this case, it must print: Protocol : Total number of units received: Percentage of correctly received units: Total number of units transmitted: Percentage of correctly transmitted units: Example with the example net_usage_file given above: Command line: net_summary.pl –p IPv4 net_usage_file Output: Protocol IP

No comments:

Post a Comment