Perl one of the main strengths of the perl programming

Assignment Help Programming Languages
Reference no: EM131110549

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 <number of cookies in the file> 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 <number of cookies in the file> cookies for host <hostname>

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

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 <number of cookies in the file> cookies expiring before or on <date in dd/mm/yyyy format>

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 <date in dd/mm/yyyy format> 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_<yourSurname>_<yourStudentID>.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.

Reference no: EM131110549

Questions Cloud

Prepare a case analysis on aviation security : Prepare a Case Analysis on Aviation Security. Review what others did regarding the case. Provide recommendations (identify courses of action; what would you do differently?)
George company manufactures a computer : George Company manufactures a computer with an estimated economic life of 12 years and leases it to National Airlines for a period of 10 years.
Shapiro inc was incorporated in 2010 : Shapiro Inc. was incorporated in 2010 to operate as a computer software service firm with an accounting fiscal year ending August 31.
Calculate the firm tax on its operating earnings only : Calculate the firm's tax on its operating earnings only. Find the tax and the after-tax amount attributable to the interest income from Zig Manufacturing bonds. Find the tax and the after-tax amount attributable to the dividend income from the Tank I..
Perl one of the main strengths of the perl programming : 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 s..
Plot the marginal tax rates : Find the marginal tax rate for the following levels of corporate earnings before taxes: $15,000; $60,000; $90,000; $200,000; $400,000; $1 million; and $20 million. Plot the marginal tax rates (measured on the y axis) against the pretax income levels ..
How to make our ideas clear : What are the main points and what makes them the main points in "how to make our ideas clear" by Charles s. Pierce?
What are culture-bound syndromes : What are culture-bound syndromes? What are some examples of culture-bound syndromes? Are culture-bound syndromes reflective of universal trends? Why or why not?
Was there a time interval when the glider was ascending : What was the maximum instantaneous rate of descent during the flight? At what time did it happen?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write c++ program that convert roman no. to decmial

Write C++ program that convert Roman no. to Decmial

  Aggregate planning for a bottling companya bottling company

aggregate planning for a bottling companya bottling company has decided to introduce a new line of premium bottled

  Create a program to compute car-s miles-per-gallon

Create a program which ask's the user for number of miles driven and gallons of gas used. It must compute the car's miles-per-gallon and show the result on the screen.

  Design a flowchart or pseudocode

Design a flowchart or pseudocode for the following:A program that accepts a candy name (for example, "chocolate-covered blueberries"), price per pound, and number of pounds sold in the average month, and displays the item's data only if it is a be..

  Design a pseudo code to create the program

Design a pseudo code to create, debug and execute the program. The documentation should include your name, course, program name, due date, programming language used

  Effective design features for site navigation

Screen shot of this example and explanation of effective design features will be included. Callouts are recommended. Ideally, students will locate examples of how they would like their site navigation to work and function.

  Write a program that allow a user to enter student names

Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input?

  Design and algorithm that compute numbers of married men

Design and algorithm that will read through the file and compute the numbers of married men, single men, married women and single women.

  Discuss the feasibility and practicality

In Coffee's (2006) article, IT professionals discuss the role application developers take in software security. Pick one of these IT experts, summarize his or her perspective on building security into software, and then discuss the feasibility and..

  Write a main program that first reads all available meals

Write a main program that first reads all available meals from a file called menu.txt. Write a function called create_event. This function is be called if a customer of the company wants to book an event.

  Create structure chart-flowchart to store taxpayer-s name

Create the structure chart, also a flowchart and pseudocode, for following problem. Suppose that each input record contains taxpayer's name.

  Design the swing applet and html test file

You can download sound clips and graphics images from Internet to use in the program. Design the Swing applet named JPartyPlanner and HTML test file to run Swing applet.

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