CP683 World Wide Web Technology

helmetpastoralΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 9 μήνες)

115 εμφανίσεις


University of Ballarat

School of Information Technology

and Mathematical Sciences

CP683 World Wide Web Technology


Worksheet 6

(Items with a ~ are optional.)

1.

Write a Perl Script to read a lin
e from standard input and write it to the screen. Check the
script for errors and then execute it.

2.

Write a Perl script to call and test the following subroutine:


sub say_hello_to {


print "Hello, $_[0]!
\
n";

}

3.

Write a Perl script to call and test the f
ollowing subroutine:


sub add {


$sum = 0;


foreach $_(@_) {



$sum += $_;


}

$sum; #last expression evaluated

}

4.

Write a Perl script to call the following subroutine with an appropriate input file:


sub km_to_miles {


s!(
\
d+)km!($1*5/8).' miles'
!ge;


s!(
\
d+)kph!($1*5/8).'mph!ge;


print;

}

5.

Write a short perl script to use the following subroutine:


sub words_in_line {


my $count = 0;


++$count while /[
\
w']+/g;


return $count;

}

6.

Write a cgi script that uses the following code to return the d
ate and time to your home
page.

($sec, $min, $hour, $month_day, $month,

$year, $week_day, $year_day, $summer_time) = gmtime();

++$month;

$year += 1900;

$the_day = (qw(Sun Mon Tue Wed Thur Fri Sat))[$week_day];