help with some scripts


  1. joshuatuscan
  2. pyuson
  3. joshuatuscan

This archived discussion is "read only".
For the corresponding "live" discussions, post in the active topic forum here.



Top 1.   Mar 25, 2003 11:21 PM

» joshuatuscan - help with some scripts

could someone please help me fix these scripts. i'm not sure why they don't work.

#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
my $radius=50;
my area=3.14159 * ($radius ** 2);
print "$area";


#!/usr/bin/perl
print "Content-type: text/html\n\n";

# the following is an array.
# An Array is a varaiable that stores multiple values.
# the values, known as elements, are referenced numerically, starrting at 0
in perl, an array name is preceded by the @ symbol.

my @arr = qw(Mike Stef Michal Anthony);

# notice that when we access an array's value, we use a $ sign before the name
# each individual element of the array is a scalar value

print "Prof #1 is $arr[0] \n"
print "Prof #2 is $arr[1] \n";
print "Prof #3 is $arr[2] \n";
print "Prof #4 is $arr[3] \n";


#!/usr/bin/perl
print "Content-type: text/html\n\n";

my %profs = ('CD' => 'Mike', AB => 'Stef', EF => 'Michal', 'XX' => 'Anthony');

print "Section AB is $profs{'AB'}
\n";
print "Section CD is $profs{'CD'}
\n
print "Section EF is $profs{'EF'}
\n";
print "Section XX is $profs{'XX'}
\n";


#!/bin/perl
print "Content-type: text/html\n\n";

# Print an array.

my @food = ("apples","pears","eels");
print @food;
$ " = " \n ";
print " @food \n";

any help is greatly appreciated. thanks

joshua

-- posted by joshuatuscan



Top 2.   Mar 26, 2003 10:01 AM

» pyuson - Re: help with some scripts

In response to message posted by joshuatuscan:

Corrections are shown with comments
First script:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
my $radius=50;
my $area=3.14159 * ($radius ** 2); #<- missing $ in area variable
print "$area\n";

Second script:
#!/usr/bin/perl
print "Content-type: text/html\n\n";

# the following is an array.
# An Array is a varaiable that stores multiple values.
# the values, known as elements, are referenced numerically, starrting at 0
#in perl, an array name is preceded by the @ symbol.

my @arr = qw(Mike Stef Michal Anthony);

# notice that when we access an array's value, we use a $ sign before the name
# each individual element of the array is a scalar value

print "Prof #1 is $arr[0] \n"; # <- missing a ; terminator
print "Prof #2 is $arr[1] \n";
print "Prof #3 is $arr[2] \n";
print "Prof #4 is $arr[3] \n";

Third script:

#!/usr/bin/perl
print "Content-type: text/html\n\n";


my %profs = ('CD' => 'Mike', AB => 'Stef', EF => 'Michal', 'XX' => 'Anthony');


print "Section AB is $profs{'AB'}
\n";
print "Section CD is $profs{'CD'}
\n"; #<- missing a ; terminator
print "Section EF is $profs{'EF'}
\n";
print "Section XX is $profs{'XX'}
\n";

#!/bin/perl
print "Content-type: text/html\n\n";


# Print an array.


my @food = ("apples","pears","eels");
print @food;
$ " = " \n ";
print " @food \n";

Fourth script:

#!/bin/perl #<- Are you sure this is right?
print "Content-type: text/html\n\n";

# Print an array.

my @food = ("apples","pears","eels");
print @food;
$ " = " \n ";
print " @food \n";

-- posted by pyuson



Top 3.   Mar 26, 2003 1:08 PM

» joshuatuscan - thank you so much

i really appreciate the help, works great now!!

-- posted by joshuatuscan



Please follow the guidelines set forth in the Suite101 Posting Etiquette when adding to the discussion.