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

Write a prolog predicate has duplicates, Write a Prolog predicate has_dupli...

Write a Prolog predicate has_duplicates(L) that is true if list L contains duplicated elements (that is at least 2 copies of an element). For instance: ?- has_duplicates([a,e,b,

NETLOGO , THERE IS ANY1 COULD HELP ME WITH NETLOGO WORK

THERE IS ANY1 COULD HELP ME WITH NETLOGO WORK

Shell script display time for user which is idle, Normal 0 fals...

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

What is an authentication subsystem, Question: (i) All Security authen...

Question: (i) All Security authentication mechanism that run on the TRU64 Unix Operating system run under the Security Integration Architecture (SIA ) layer. Explain with di

Assembly language programm , these 8 numbers (15, 20, 25, 30, 35, 40, 45, a...

these 8 numbers (15, 20, 25, 30, 35, 40, 45, and 50) with using conditional jump

Create a linux shell, Create a linux shell (in other words, write a C/C++ p...

Create a linux shell (in other words, write a C/C++ program) that will recursively prompt for input from the user. The shell should prompt as yourRollNumber-currentDirector

C++, Have the user input two values. Store them in variables called saving...

Have the user input two values. Store them in variables called savings and expenses, both of data type double. If expenses is less than savings, subtract expenses from savings, o

Shell script delete all lines from file contains word mca, Normal 0 ...

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

Prelude to Programming, How does a Case Structure differ from a Case struct...

How does a Case Structure differ from a Case structure program in pseudocode

Code html and xml, Topic Develop a Web site that will provide informat...

Topic Develop a Web site that will provide information about your organization. The Web site will need to have a user-friendly interface for users to enter their information;

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