Write a perl program that manage browser cookies

Assignment Help Programming Languages
Reference no: EM13923614

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 <number of cookies in the file>?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 <number of cookies in the file>cookies with name <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 <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 <number of cookies in the file>cookies persisting after <date in dd/mm/yyyy format>

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 <date in dd/mm/yyyy format>

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_<yourSurname>_<yourStudentID>.zip and submit it with the modalities specified above. Several free zip utilities are available on the WWW.

Reference no: EM13923614

Questions Cloud

What is the net present value of the project : Suppose Palmer Properties is considering investing $2.6 million today (i.e., C0 =-2,600,000) on a new project that is expected to last for 7 years. What is the payback period for the project? What is the net present value of the project? What is the ..
Calculate equity value of margin account on settlement date : Calculate the equity value of your margin account on each settlement date, including any additional equity required to meet a margin call.
What is this bonds effective yield-to-maturity : Suppose that you have a bond that is currently trading for 1,234.56, has a time-to-maturity of 14 years, pays semi-annual coupon payments of $35.50, and a face value of $1,000. Also, suppose that the bond was purchased 90 days after its last, semi-an..
Risk and return and coefficient of variation based : Risk and Return, Coefficient of Variation Based on the following information, calculate the coefficient of variation and select the best investment based on the risk/reward relationship. Std Dev. Exp. Return Company A 7.4 13.2 Company B 11.6 18.9
Write a perl program that manage browser cookies : 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".
Describe the evolution of the technology and the impact : Think of a technology that has evolved, or is evolving that has an impact on your business, your organization, or an industry you are familiar with. Describe the evolution of the technology and the impact
What products formed when nitroglycerin undergoes hydrolysis : Which of the following statements is INCORRECT regarding regulatory agencies that have some responsibilities in minimizing risks associated with radioactive materials in the United States?
Calculate intrinsic value and time value of call-put options : Assume that the euro is trading at a spot price of USD/EUR 1.49. Further assume that the premium of an American call (put) option with an exercise price of $1.50 is 1.55 (3.70) cents. Calculate the intrinsic value and the time value of the call and p..
Accounts receivable using probability proportional : You are the auditor for a company and need to review the company's accounts receivable using probability proportional to size (PPS) sampling. In addition, the board of directors has requested that you and your team present an explanation of your P..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write program to help students learn periods of geology time

You are taking a geology class, and the professor wants you to write a program to help students learn the periods of geologic time. The program should let the user enter a range of prehistoric dates (in millions of years), and then output the peri..

  Create default constructor which invokes superclass

Create a (default) constructor which invokes superclass constructor with value 3 (law school is typically a three year program).

  Write a procedure make-accumulator

Write a procedure (make-queue) that produces independent first-in-first-out queue objects, using a message-passing style.

  Write non-recursive function-compute n-th fibonacci number

Fibonnacci series 0,1,1,2,3,5,8,13,21,... starts with terms 0 and 1 and has property that each succeeding terms is sum of the two preceding terms. Write the non-recursive function which computes the n'th Fibonacci number.

  Advantages of using invisible html table to create web page

What advantages do you see in using an invisible HTML table to structure an entire Web page? What disadvantages does the table structure pose?

  Write pseudocode-read in data file containing student name

Write a pseudocode to do the following Read in data file containing student names, ID number, and gender into an array.

  Which protocol is using by video game programmers udp or tcp

What protocol do you think video game programmers would use UDP or TCP. Why do you think the game uses one or the other protocols

  Small game development

Small game development - the development has to be done in PROLOG LANGUAGE.

  Write program which prompts for boiling point of substance

Write program which prompts user for observed boiling point of substance in Centigrade and identifies substance if observed boiling point is within 5% of the expected boiling point.

  What do you meant by abstract keyword

What does the abstract keyword do and what are generics as they relate to the built in linked list class? Why do we need them?

  Write pseudocode for procedure construct-optimal-bst

Write pseudocode for procedure Construct-Optimal-BST (root) which, table root, outputs structure of the optimal bimary search tree.

  Write a perl program

Write perl program which will run on my system and will start another perl program on another linux system. The main program should wait for linux perl program to complete its work and send the result to my main perl program.

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