Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Title: Cookies management with Perl

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 "brows er 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 four fields separated by commas.

c. The four fields are: cookie name, cookie value, hostname and expiry date.

d. The first three fields are strings of arbitrary (yet reasonably limited) length; the characters in these strings can be any of: uppercase letters, lowercase letters, decimal digits, the underscore and the dot.

e. The expiry date field is a string of decimal digits in the so-called Unix epoch format.

The following example is the ultimate specification for the format of file cookies_file:

SessionID,029380,xyz.org.au,1385874000ASPX_ANONYMOUS,CjnjrB,xyz.org.au,1356912000 SESSION_COLOUR,red,nosite.com.au,1341014400SESSION_ACTIVE,FALSE,nosite.com.au,1341014400 username001,massimo.piccardi,hello.uts.edu.au,2145830400username012,john.smith,hello.uts.edu.au,2145830400 username013,michael.zhang,hello.uts.edu.au,2145830400

Important note: your program does not need to verify that file cookies_file complies with the format 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 Example with the example cookies_file given above:

Command line:

cookiemgr.pl cookies_file

Output:

Found 7 cookies

In the case in which file cookies_file is empty, your program must instead only print:

No cookies found

5. Your program can be invoked with option: -h hostname. In this case, it must only print the following string:

Found cookies for host

Example with the example cookies_file given above:

Command line:

cookiemgr.pl cookies_file -h nosite.com.au

Output:

Found 2 cookies for host nosite.com.au

Option -h hostname can only be used once per command line (you can only ask for the cookies of one host at a time). In the case in which file cookies_file contains no cookies for the given hostname, your program must instead only print: No cookies found for host

Example with the example cookies_file given above:

Command line:

cookiemgr.pl cookies_file -h feit.uts.edu.au

Output:

No cookies found for host feit.uts.edu.au

6. Your program can be invoked with option: -d date, where date is entered in dd/mm/yyyy format. In this case, it must only print the following string:

Found cookies expiring before or on

To find the cookies expiring before, or on, the date given in the option, your program must convert this date to the Unix epoch format and compare it with the dates stored in cookies_file. The time of the date is always assumed to be 0 hours, 0 minutes, 0 seconds and the time used is the Coordinated Universal Time (UTC), also often referred to as Greenwich Mean Time (GMT). Perl has a function for converting a GMT time to the Unix epoch time.

Example with the example cookies_file given above:

Command line:

cookiemgr.pl cookies_file -d 31/12/2012

The Unix epoch format for 31/12/2012, midnight, is 1356912000. In file cookies_file there are three dates which are smaller or equal than 1356912000. Therefore, the output must be:

Found 3 cookies expiring before or on 31/12/2012

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 -d 31/05/2010

The Unix epoch format for 31/05/2010, midnight, is 1275264000. In file cookies_file there are no dates which are smaller or equal than 1275264000. Therefore, the output must be:No cookies found expiring before or on 31/05/2010

7. Your program can be invoked with option: -s. In thi s 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 -h hostname; 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 what specified above, it must only print the following string to the standard output:

Invalid syntax/options Example:

Command line:

cookiemgr.pl cookies_file UTS.txt -v

Output:

Invalid syntax/options

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.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91868145
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Programming Language

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

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 ...

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 ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

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 arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

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 ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

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 ...

  • 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