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

Amen, Write a program that inputs two positive integers of, at most, 20 dig...

Write a program that inputs two positive integers of, at most, 20 digits and outputs the sum of the numbers. If the sum of the numbers has more than 20 digits, output the sum with

Rewrite the xhtml code, Below is an example of an invalid XHTML page. Your ...

Below is an example of an invalid XHTML page. Your goal is to rewrite the code so that: No deprecated/obsolete tags are being used All elements are nested correctly (i.e

Create xml documents to contain well-defined information, The objectives of...

The objectives of this assignment are to test your ability to create XML documents to contain well-defined information. This assignment will be used further in Assignment 2, so ple

Write a script for explicitly display of values, Write a script called 'pro...

Write a script called 'prob1.m' that solves for the variables y, and z in terms of a user inputed x. The variables y and z are defined as follows: y = x - 30                when

Computes the least squares fit of the data, Your solution to the problem sh...

Your solution to the problem should be housed within a while loop, which allows the grader to test your solution repeatedly without having to re-execute the script, as shown in cla

Write a procedure to prints the avl tree, (a) Write a procedure called (loo...

(a) Write a procedure called (lookup n t). This procedure has 2 arguments: n is the value being looked up, t is the AVL tree. The subtree with n as its root is returned (or '() if

Assembly language coding, i need a coding to glow 8 LEDs on a port with pwm...

i need a coding to glow 8 LEDs on a port with pwm effect

Board coloring problem description, Board Coloring Problem Description ...

Board Coloring Problem Description In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color.

Program to output a triangle wave, 1.) Write a flowchart and program to do ...

1.) Write a flowchart and program to do the following: A pressure sensor in a cooling system measures the pressure of the refrigerant and is connected to Port -1 of the 8051. If th

Shell script to display system time in words, Normal 0 false ...

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

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