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

Define parameter passing mechanism - computer programming, Define the Param...

Define the Parameter Passing Mechanism - Computer Programming? The Parameters are syntactically identifiers and they are used within the body of the function and sometimes the

Assignment help, Write your own version of the strcmp function string_compa...

Write your own version of the strcmp function string_compare. Supply a main program that will test each of the 3 differing outcomes. int string_compare(char *s, char *t); retu

Write a program to list the intermediate films sandwiched, We want a progra...

We want a program, a logic, we can list the intermediate films sandwiched between the 2 tapes (from - to) that indicates the user. example: From to

A Simple Distributed Computing Platform , You are asked to develop a replic...

You are asked to develop a replicator (client) that distributes a large job over a number of computers (a server group) on a single switched LAN (our BU04 lab). In this assignment,

We need help for build a price quote generator, We need help for build a Pr...

We need help for build a Price Quote Generator I am interested in two things (A) a web based system that will allow a user to enter the parameters of their contests (there are o

Triple eigenvalue with 3 linearly independent eigenvectors, 1 Triple Eigenv...

1 Triple Eigenvalue with 3 Linearly Independent Eigenvectors In this case we will have the eigenvalue l with the three linearly independent eigenvectors  ?h 1 , ?h 2 and  ?h

Java, program take integer from user and print in alphabets

program take integer from user and print in alphabets

Visual basic.net, how to create a screen for messages for a data transmissi...

how to create a screen for messages for a data transmission system

Improved support for javascript debugging, Improved Support for JavaScript ...

Improved Support for JavaScript Debugging ASP.NET has many benefits over vintage ASP in the place of debugging. You can now quickly debug your server-side value using the complete

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