Explore BrainMass

PERL: Creating a Script that Process the Data

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');

$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";

© BrainMass Inc. brainmass.com July 21, 2018, 7:32 pm ad1c9bdddf

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

Solution Summary

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