• Home
  • Textbooks
  • CGI/Perl (Web Warrior Series)
  • User-Defined Functions

CGI/Perl (Web Warrior Series)

Diane Zak

Chapter 7

User-Defined Functions - all with Video Answers

Educators


Chapter Questions

01:05

Problem 1

A function is a block of code that begins with the Perl keyword _______________________
a. block
b. function
c. func
d. sub

Gregory Higby
Gregory Higby
Numerade Educator

Problem 2

The code for a user-defined function_______________________
a. must be entered in the same file as the calling statement
b. can be entered in the same file as the calling statement
c. can be entered in a file separate from the calling statement
d. both $b$ and $c$

Check back soon!
01:26

Problem 3

Which of the following statements calls a user-defined function named calc_netpay, and assigns the function's return value to the $$\$ $$net variable?
a. calc_netpay( ) ;
b. calc_netpay ( ) = $$\$ net$$;
c. $$\$net$$ = calc_netpay ( ) ;
d. calc_netpay ($$\$net$$) ;

Ernest Castorena
Ernest Castorena
Numerade Educator
06:20

Problem 4

Which of the following statements calls a user-defined function named calc taxes, and assigns the function's return values to the $$\$ federal $$ 1 and $$\$state $$ variables?
a. $$(\$ federal $$, $$\$state $$)=Z calc_taxes () ;
b.$$\$federal $$, $$\$ state $$ = calc_taxes();
c. calc_taxes ()$=$ $$(\$ federal $$, $$\$state $$);
d. both $a$ and $b$

Gaurav Kalra
Gaurav Kalra
Numerade Educator

Problem 5

The return statement is required in a function definition.
a. true
b. false

Check back soon!

Problem 6

The ____________________function terminates a script.
a. end
b. exit
c. halt
d. stop

Check back soon!

Problem 7

Perl stores the arguments passed to a user-defined function in an array named
a. @__
b. __@
c. $$\$ $$__
d. %ENV

Check back soon!

Problem 8

Variables declared in the main section of a script are available to the main section and to any functions defined within the script.
a. true
b. false

Check back soon!
02:20

Problem 9

Which of the following statements determines the number of characters stored in the \$email variable, and then assigns the result to the \$num_char variable?
a. $$\$ $$num_char = len $$\$ $$ email $)$;
b. $$\$ $$num_char = length $$\$ $$ semail $)$;
c. $$\$ $$num_char = num $$\$ $$ email $)$;
d.$$\$ $$num_char = size $$\$ $$ email);

Willis James
Willis James
Numerade Educator

Problem 10

Environment variables are stored in a hash named _______________________
a. @__
b. %__
c. %ENV
d. None of the above.

Check back soon!

Problem 11

What are the two reasons that programmers create user-defined functions?

Check back soon!
00:34

Problem 12

List the three parts of a function definition.

Matt Gibson
Matt Gibson
Numerade Educator
04:27

Problem 13

When the angle operator $(<>)$ reads a record, it temporarily stores the record in the ____________________ variable.

James Kiss
James Kiss
Numerade Educator

Problem 14

The first argument passed to a user-defined function is stored in a scalar variable named _________________

Check back soon!

Problem 15

When you click a link that is associated with a CGI script, the REQUEST_METHOD is automatically set to ___________________

Check back soon!

Problem 16

Write a statement that prints the method used to send form data.

Check back soon!
01:35

Problem 17

Write a return statement that returns the result of multiplying the contents of the $$\$ $$hours variable by the contents of the $$\$ $$rate variable.

Carrie Caldwell
Carrie Caldwell
Numerade Educator

Problem 18

Write a return statement that returns the contents of the $$\$ $$name and $$\$ $$age variables.

Check back soon!

Problem 19

Write a function header for a user-defined function named display_errors.

Check back soon!
01:48

Problem 20

Write a while loop that prints the numbers 1 through 5 .

Patina Herring
Patina Herring
Numerade Educator