Tech Support Guy banner
Not open for further replies.
1 - 1 of 1 Posts

· Registered
203 Posts
Discussion Starter · #1 ·
I have a Perl assignment that is driving me nuts. Here is what I don't understand.

1)How to get the ages to work like the names do.
2)How to get the names and ages to be displayed together.
3)How to show how many years till 25 that they are.

Below is the assignment and the coding.

Here is my assignment:

--Format an HTML page
--Declare an array of 10 names
--Add 3 new names to the name array
--Declare an array of 10 ages for the original 10 names
--Uses a control structure to:
--Print each name and age
--Print each name and the age the person will be in 25 years.
--Declare 2 numbers $a=2523 and $b=11 and perform the operations listed below. You may assign these values to new scalar variables:
--concatenate $a and $b to create $c -- print the value of $c
--repeat $c two times and print its value
--square $a and print the result
--divide $c by $a
--Determine the modulus of $c divided by $b
--Design and develop another feature for the program:
--Be sure to use comments to describe the feature.

Here is my coding thus far:

#!/usr/bin/perl Part B
print "Content-type: text/html\r\n\r\n";
print "Assignment#4";
print "
Assignment 4​

my @names;
$names[0]="Miguel ";
$names[1]="Roberto ";
$names[2]="Julio ";
$names[3]="Jorge ";
$names[4]="Mateo ";
$names[5]="Juan ";
$names[6]="Guillermo ";
$names[7]="Diego ";
$names[8]="Pablo ";
$names[9]="Antonio ";
my @ages;
foreach $names (@names) { print $names;};
foreach $ages (@ages) { print $ages;};
print 'Now, enter three more names:';
for(my $i=10;$i<13;$i++)
print $names[$i];
print "
This Totals 13 Names";
print "

Please declare 2 numbers \$a=2523 and \$b=11.
print "
The number is called \$c and its value is: ";
print $c;
print "
The total from repeating \$c two times is: ";
print "

The value of \$a squared is: ";
print $a **2;
print "

The answer when you divide \$c by \$a is: ";
print $c/$a;
print "

The modulus of \$c divided by \$b is: ";
print $c%$b;
print "

Design and develop another feature for the program.
print "
When you take \$a and subtract \$b, you get a difference of ";
#This will simply subtract $b from $a;
print $a-$b;
print ".
print "";
1 - 1 of 1 Posts
Not open for further replies.