Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Cookies management with Perl

One of the main strengths of the Perl programming language is its support for text manipulation. In this assignment, you will use it 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 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_filecan 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
bothname 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/yyyyformat.

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_filecomplies 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 ?Example with the example cookies_filegiven above: ?Command line: ?cookiemgr.pl cookies_fileOutput:

Found 6 cookies

In the case in which file cookies_filebe 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_filegiven above:
Command line:
cookiemgr.plcookies_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_filecontains no cookies with the given name, your program must instead only print:

No cookies found with name

Example with the example cookies_filegiven above:
Command line:
cookiemgr.plcookies_file-n bkgcolorOutput:
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 givendate.
Example with the example cookies_filegiven above:
Command line:
cookiemgr.plcookies_file-d 01/01/2014

Output:
Found 3 cookies persisting after 01/01/2014

since there are 3 cookies in the example cookies_filewhich 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_filecontains no cookies persisting after the given date, your program must instead only print:

No cookies found persisting after

Example with the example cookies_filegiven above:
Command line:
cookiemgr.plcookies_file-d 31/05/2020
Output:
No cookies found persisting after 31/05/2020

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.plcookies_file-Z alpha
Output: ?
Syntax error: invalid syntax

10. Zip your file cookiemgr.pl into a file named USP__.zip and submit it with the modalities specified above. Several free zip utilities are available on the WWW.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91596502
  • Price:- $180

Guranteed 48 Hours Delivery, In Price:- $180

Have any Question?


Related Questions in Programming Language

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As