(1) What is the exact output of the following Perl program? (pp 40,50)
#!/public/bin/perl $a = "one"."two"; $b = "\nthree\n"; print $a; print $b; answer: onetwo three
(2) What is the exact output of the following Perl program (pp 40-41,46-48)
#!/public/bin/perl $a = "abcdefg"; while ($a ne "") { $b .= chop($a); } print "a: $a\n"; print "b: $b\n"; answer: a: b: gfedcba
(3) Modify the program in (2) so that the scalar variable $a gets its
initial value from the keyboard. Change the print statements so that
the output of the program is always in upper case letters.
(pp 39 backslash escapes,47 chop() operator,49
answer: #!/public/bin/perl
chop($a = <STDIN>);
while ($a ne "") {
$b .= chop($a);
}
print "\Ua: $a\n";
print "\Ub: $b\n";