Explore BrainMass

How to read data using Perl

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

How do you read data using Perl?

See the attached file.

© BrainMass Inc. brainmass.com October 16, 2018, 6:32 pm ad1c9bdddf


Solution Preview

See the attached file.
while (<DATA>) { #while the handle DATA is true; it has more lines
print unless ...

Solution Summary

Gives an example piece of Perl code that shows how to read data until a search string is found.

Similar Posting

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

View Full Posting Details