Cookies management with perl, Programming Languages

Assignment Help:

One of the main strengths of the Perl programming language are its powerful text manipulation features. In this assignment, you will put them to use for writing a Perl program that can manage a simplified version of the so-called "browser cookies".

These are the specifications for your Perl program:

1.  The file with your program must be named cookiemgr.pl

2.  The program 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 string: Error: a valid file must be passed as first argument to the standard output and exit. The first argument is compulsory while the following arguments are 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).

b. Each line must contain three fields separated by commas.

c. The three fields are:

Cookie name, size in bytes and expiry date

d. The cookie name field must be a string with the following format: cookie:username@webaddress

username  is a string of minimum 1 character and maximum 8 characters arbitrarily chosen in ranges a-z, A-Z, 0-9;

webaddress is a string encoding a web address; it cannot contain any @ character. e.  The size in bytes field must be a string encoding a positive integer number. 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: cookie:[email protected],348,12/01/2013

cookie:[email protected],322,31/12/2012

cookie:[email protected],36,30/06/2012

cookie:[email protected],128,31/12/2037

cookie:[email protected],36,30/06/2011

cookie:[email protected],48,23/11/2012

cookie:[email protected],128,01/09/2015

3. 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.

4.  Your program can be invoked without any options. In this case, it must only print the following string:

Found cookies for a total size of bytes

Example with the example cookies_file given above: Command line:

cookiemgr.pl cookies_file Output:

Found 7 cookies for a total size of 1046 bytes

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: -u username. In this case, it must only print the following string:

Found cookies for user for a total size of bytes

Example with the example cookies_file given above: Command line:

cookiemgr.pl cookies_file -u massimo Output:

Found 3 cookies for user massimo for a total size of 512 bytes

Option -u username can only be used once per command line (you can only ask for the cookies of one user at a time).

In the case in which file cookies_file contains no cookies for the given username, your program must instead only print:

No cookies found for user

Example with the example cookies_file given above: Command line:

cookiemgr.pl cookies_file -u george Output:

No cookies found for user george

6.  Your program can be invoked with option: -d date. In this case, it must only print the following string:

Found cookies expiring before or on for a total size of bytes

Example with the example cookies_file given above: Command line:

cookiemgr.pl cookies_file -d 31/12/2012 Output:

Found 4 cookies expiring before or on 31/12/2012 for a total size of 442 bytes

Option -d date can only be used once per command line (you can only ask for the cookies for a given date at a time).

In the case in which file cookies_file contains no cookies expiring before or on the given date, your program must instead only print:

No cookies found expiring before or on Example with the example cookies_file given above:

Command line:

cookiemgr.pl cookies_file -u 31/05/2011 Output:

No cookies found expiring before or on 31/05/2011

7.  Your program can be invoked with option: -s. In this case, it must only print your name, surname and student ID in a format of your choice.

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 -u username; 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:

Invalid sintax

Example:

Command line:

cookiemgr.pl cookies_file UTS.txt -v Output:

Invalid syntax

10.  Zip your file cookiemgr.pl into a file named

USP__.zip and submit it with the modalities specified above.

Please be reminded that:

  • This assignment must be your own work and you should not be helped by anyone to prepare it in any way;
  • The submission of the assignment is not compulsory to pass the subject and it only counts for ten marks;
  • understanding the assignment specifications is part of the assignment itself and no further instructions will be provided; on the other hand, whatever is not constrained you can implement it according to your own best judgment.

Related Discussions:- Cookies management with perl

Draw the sequence diagram for the scenario, Draw the sequence diagram for t...

Draw the sequence diagram for the following scenario of eBroker. Sell Stock The user enters the username and password The system checks that the user is a valid user

Explain the various tools for software implementation, Problem 1. What ...

Problem 1. What are the potential advantages of treating two related classes as subclasses of some superclass? 2. Explain the various tools for software implementation 3.

Simple corba program, You are working in charge of a group of programmers a...

You are working in charge of a group of programmers at a software company. Your task is to assess and research CORBA and to produce a report to be given to the programmers detailin

Recursive decent parser, Given grammar Grammar M following: 1 - - > b...

Given grammar Grammar M following: 1 - - > begin end 2 - - > 3 - - > 4 - - > ? 5 - - > Id : = ; 6 - - > read ( ) ; 7 - - > write ( )

Program for tube challenge route, 1. Introduction The Tube Challenge is ...

1. Introduction The Tube Challenge is a Guinness World Records challenge that tests both the physical and mental abilities of the person trying to break it. The main components

Systems of differential equations, In this section we need to take a brief ...

In this section we need to take a brief look at systems of differential equations which are larger than 2 x 2. The problem now is not like the first few sections where we looked at

.net class library, .NET class library .NET structure comes with just on...

.NET class library .NET structure comes with just one category selection. And that all developers need to learn!! Whether they create the value in C# or VB.NET or J#, it doesn't

Design and create a new class, You are to design and create a new class cal...

You are to design and create a new class called SelectCallDataDialog, which opens by clicking browse  buttons for selection of ringtones,  vibrations or leds. Depending on which th

Mathematical expression of linear programming problem, A Consultant Dietici...

A Consultant Dietician provides diet and nutritional advice to clients. A client's diet requires that all the food s/he eats come from one of the four "basic food groups" (chocolat

Variation of parameter, VARIATION OF PARAMETERS - HIGHER ORDER DIFFEREN...

VARIATION OF PARAMETERS - HIGHER ORDER DIFFERENTIAL EQUATIONS We now require taking a look at the second method of finding a particular solution to a differential equation

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