Read file in Perl, Programming Languages

Assignment Help:
These are the specifications for your Perl program:
1. The file containing your program must be named cookiemgr.pl
2. It must be invoked as:
cookiemgr.pl cookies_file [options]
The program must check that its first argument exists, is a file and is readable. If not, it must
print an error message to the standard output and exit. The first argument is compulsory while
the second argument is optional. The arguments are described in the following.
3. File cookies_file can have any arbitrary name. It must be a file of text with the following
format:
a. The file consists of an arbitrary number of lines (including, possibly, zero lines). Each
line corresponds to a cookie.
b. Each line must contain three fields separated by semicolons.
c. The three fields are: name-value pair, domain and expiry date.
d. The name-value pair field must be a string with the following format:
name=value
both name and value are strings of minimum 1 character and maximum 20 characters
arbitrarily chosen in ranges a-z, A-Z, 0-9.
e. The domain field is a string encoding a web address; it can contain a maximum of 100
characters from the set above, plus the period (.).
f. The expiry date field must be a string encoding a date in the dd/mm/yyyy format.
The following example is the final specification for the format of file cookies_file:
color=red;xyz.org.au;01/12/2013
username=Massimo;xyz.org.au;01/12/2013
fontface=bold;www.nosite.com.au;30/06/2014
color=white;www.hello.uts.edu.au;31/10/2013
username=Matt;www.nosite.com.au;30/06/2014
fonttype=Times;www.hello.uts.edu.au;01/09/2018
Important note: your program does not need to verify that file cookies_file complies with the
specifications. You can simply assume that the file meets all the specifications given above. Subject: 32547 UNIX Systems Programming, Spring 2013 - Assignment
4
4. Your program can be invoked without any options. In this case, it must only print the
following string:
Found
Example with the example cookies_file given above:
Command line:
cookiemgr.pl cookies_file
Output:
Found 6 cookies
In the case in which file cookies_file be empty, your program must instead only print:
No cookies found
5. Your program can be invoked with option: –n name. In this case, it must only print the
following string:
Found cookies with name
Example with the example cookies_file given above:
Command line:
cookiemgr.pl cookies_file –n username
Output:
Found 2 cookies with name username
Option –n name can only be used once per command line (you can only ask for the cookies
with one given name at a time).
In the case in which file cookies_file contains no cookies with the given name, your program
must instead only print:
No cookies found with name Subject: 32547 UNIX Systems Programming, Spring 2013 - Assignment
5
Example with the example cookies_file given above:
Command line:
cookiemgr.pl cookies_file –n bkgcolor
Output:
No cookies found with name bkgcolor
6. Your program can be invoked with option: –d date. In this case, it must only print the
following string:
Found cookies persisting after
The string above reports the number of cookies that will still exist (i.e., persist) after the given
date.
Example with the example cookies_file given above:
Command line:
cookiemgr.pl cookies_file –d 01/01/2014
Output:
Found 3 cookies persisting after 01/01/2014
since there are 3 cookies in the example cookies_file which are set to expire after the given
date (those with expiry dates: 30/06/2014, 30/06/2014 and 01/09/2018, orderly).
Option –d date can only be used once per command line (you can only ask for the cookies with
a given date at a time).
In the case in which file cookies_file contains no cookies persisting after the given date, your
program must instead only print:
No cookies found persisting after
Example with the example cookies_file given above:
Command line:
cookiemgr.pl cookies_file –d 31/05/2020
Output:
No cookies found persisting after 31/05/2020 Subject: 32547 UNIX Systems Programming, Spring 2013 - Assignment
6
7. Your program can be invoked with option: –s. In this case, it must only print your name,
surname, student ID and date of completion of your assignment, in a format of your choice.
Please note that the first argument is still required.
8. The options cannot be used simultaneously. This means that your program can only be invoked
in the following way: 1) with no options; 2) with option –n name; 3) with option –d date; 4)
with option –s.
9. If your program is invoked with a valid first argument, but any other syntax than those
specified above, it must only print the following string:
Syntax error: invalid syntax
and exit.
Example:
Command line:
cookiemgr.pl cookies_file –Z alpha
Output:
Syntax error: invalid syntax

Related Discussions:- Read file in Perl

Shell script to print right traingle, Normal 0 false false ...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Special matrices, Special Matrices There are some "special" matrices o...

Special Matrices There are some "special" matrices out there which we may use on occasion. The square matrix is the first special matrix.  A square matrix is any matrix that s

Linux assignment , Hi how can I upload my hw to you experts?

Hi how can I upload my hw to you experts?

Create a structure to represent deck of cards, We want to create a structur...

We want to create a structure that will represent a deck of cards (not necessarily full). Each card has a character (between '2' to '9' and 'T', 'J', 'Q', 'K', 'A') and a suit (dia

Triple eigenvalue with one eigenvector, Triple Eigenvalue with 1 Eigenvecto...

Triple Eigenvalue with 1 Eigenvector The eigenvalue/vector pair in this case are l and  ?h , . Since the eigenvalue is real we know as the first solution we require is, e l

Java reflection api, Expertsmind brings you unique solution in java assign...

Expertsmind brings you unique solution in java assignments Reflection API Uses of Reflection with java assignment help Reflection is widely used by applications which

Java program, Write a java program for inserting a particular node.

Write a java program for inserting a particular node.

General Programming , #questCustomers of a particular restaurant are descri...

#questCustomers of a particular restaurant are described with some categories. If the categories indicate the customer is a senior citizen, or the customer works for the restaurant

Shell script to print the name of file that has maximum size, Normal 0 ...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

GUI(VB.NET), Can you please make my assignment in 3 days?I will pay you goo...

Can you please make my assignment in 3 days?I will pay you good

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd