Purchase Solution

PERL: Creating a Script that Process the Data

Not what you're looking for?

Ask Custom Question

New to PERL so I'm suppose to create a script that processes the data (name and number of hours worked during the month) submitted using an online form.The script calculates the number of weeks, days, and hours worked during the month, then displays the form data and the results of the calculations.

I keep getting this compilation error -

"Can't modify division (/) in scalar assignment near $weeks"

Here's my code:
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
$query = new CGI;

# Variables
my $name; #Employee's name
my $hours; #Hours Worked per month
my $weeks;
my $days;
my $hour;
my $remainder;

#Read the user's form input
$name = $query->param('name');
$hours = $query->param('hrs');

#Calculations
$hours /40 = $weeks;
$remainder = ($hours % 40);
($remainder / 8) = $days;
($remainder / 5) = $hour;

#HTML response to user
print "Content-type:text/htmlrnrn";
print "<HTML><BODY>n";
print "Hello, $name.n";
print "You have entered a total of $hours work hours.n";
print "For this month, you have worked $weeks week/s, $days days, and $hour hours.n";
print "</BODY></HTML>n";

Purchase this Solution

Solution Summary

The solution assists in creating a script that processes the data submitted using an online form.

Solution Preview

The key to this solution is in the calculations to determine the weeks, days, and hours that the given number of worked hours represents. The following code is where ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.