Networking Chapter 9 Homework Name Least One Difference Between Perl And AWK Programming answer Some Differences Between

subject Type Homework Help
subject Pages 6
subject Words 1539
subject Authors Michael Palmer

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
1
Guide to UNIX Using Linux Fourth Edition
Chapter 9 Solutions
Answers to the Chapter 9 Review Questions
1. Which of the following describes Common Gateway Interface (CGI). (Choose all that apply.)
2. Your colleague is writing a Perl script and wants to determine if two strings are the same. He is
used the = operator, but it is not working properly. What is the problem?
3. In Perl a variable that starts with $, such as $value, ________________. (Choose all that apply.)
4. Which of the following operators is used to access data in an open file in Perl? (Choose all that
apply.)
5. You are training a new employee and have been asked to help him learn Perl. Which of the
following statements can you use to help describe Perl? (Choose all that apply.).
6. You have created the following expression in Perl: $value < 2842. What does this expression
mean?
7. A programmer in your group has written the following subroutine, which does not work. What is
the problem?
run sort
{
if ($a < $b) { -1; }
elsif ($a == $b) { 0; }
else { +1; }
}
>
8. One of your colleagues has written a Perl script, but it does not run on some people’s computers
who use a different Linux distribution or who do not use the Bash shell. Which of the following
might be the problem?
9. A colleague at work has overheard you discussing the spaceship operator and is curious about
what this is. What do you tell him?
10. You are writing a Perl script that uses a segment of code over and over again, and you are tired of
repeatedly typing in this code. Which of the following should you do?
page-pf2
11. Which of the following are automatically opened by Perl? (Choose all that apply.)
12. In the following statement, when is “Could not open students file” displayed?
open (FILEIN, "students") || warn "Could not open students
file \n" ;
13. When you make a Web page using HTML, what line do you start with to show that what follows
after that line consists of HTML tags?
14. Which of the following is an example of a scalar? (Choose all that apply.)
15. You have written the following line in a Perl program:
$filein = $ARGV[0];
What is the purpose of this line?
16. In Perl, the control sequence \n is used to ________________.
17. You are creating a data file for an inventory system. Which of the following is a common file
extension to show this is a data file?
18. Perl supports using which of the following logic structures? (Choose all that apply.)
19. In Perl, strings are surrounded by which of the following? (Choose all that apply.).
20. You colleague is creating an HTML-based Web page and wants the first line to have the largest
heading size, and so he uses the tag <LARGEHEAD>. This tag isn’t producing the expected
result. What tag should he use instead?
21. When you assign values for an array, what character should precede the name of the array?
22. What arithmetic operators are used in Perl scripts?
23. What is a filehandle in Perl?
page-pf3
3
24. Name at least one difference between Perl and Awk programming.
25. Name five data types used by Perl.
Hands-On Projects Tips and Solutions for Chapter 9
Project 9-1
In this project, students create a Perl script which illustrates how to pass a file name on the command
line using the standard array variable ARGV[0]
Project 9-2
This project shows students how to create a Perl script to open a file from within a program.
Project 9-3
In this project, students create a Perl script to sort words.
Project 9-4
.
For this project, students access a file in Perl by passing the filename on the command line.
Project 9-5
In this project, students sort a numeric field using a subroutine in Perl.
Project 9-6
page-pf4
Discovery Exercises
1. Write a Perl script to display the line “Perl was developed by Larry Wall”.
2. Write a Perl script in which you create a variable in the script to contain the name Beth and then
have the script display “Welcome Beth.”
3. Modify the script you wrote in Exercise 2 so that you prompt for the name and then display
“Welcome name.
4. Write down four scalar variables, two of which are numeric and two that are strings.
5. Create a Perl program that uses an array of vegetablespeas, carrots, spinach, corn, beansand
in which all of the vegetables in the array are displayed to the screen.
6. Design a Perl program that sorts the last names Martin, Adams, Sandoval, Perry, Yablonsky,
Brown, and Ramirez..
page-pf5
5
7. Write a Perl program that attempts to open a file that does not exist, and that prints the message
“That file is nonexistent.”.
8. Write a Perl program that converts a value in inches to a value in centimeters and displays the
result. (1 inch = 2.54 centimeters.).
9. Create a Perl program that sorts the numbers 115, 10, 19, 35, and 2 and that uses the spaceship
operator to accomplish the sort.
10. Write a Perl program that contains a hash variable and displays the keys. The hash variable
contains the following key and value combinations:
page-pf6
Key
Value
1
Martin
2
Hanson
3
Stephens
4
Rawlins

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.