• Home
  • Textbooks
  • CGI/Perl (Web Warrior Series)
  • DBM Databases

CGI/Perl (Web Warrior Series)

Diane Zak

Chapter 9

DBM Databases - all with Video Answers

Educators


Chapter Questions

Problem 1

Which of the following functions binds a hash to a DBM database?
a. bind
b. bindhash
c. tie
d. hashtie

Check back soon!

Problem 2

You use the __________ function to determine if a DBM database contains a specific key.
a. exist
b. find
c. found
d. None of the above.

Check back soon!
06:40

Problem 3

Which ot the following statements opens a DBM database named citystate for both reading and writing?
a. open ( "citystate" , "«",
b. opendb(%city, "SDBM_File", "citystate", READWR, 0);
c. tie(%city, "SDBM_File", "citystate", RDWR);
d. tie(%city, "SDBM_File", "citystate", 0_RDWR, 0);

Puneet Prajapati
Puneet Prajapati
Numerade Educator
01:47

Problem 4

Which ot the following statements writes the key “Atlanta” and the value “GA” to a DBM database named citystate? The database is tied to the %city hash.
a. %city{GA> = "Atlanta";
b. $$\$citystate{Atlanta}$$ = "GA";
c. $$\$city{Atlanta}$$ = "GA" ;
d. None ot the above.

Maria Dearborn
Maria Dearborn
Numerade Educator
04:31

Problem 5

Which of the following statements closes the citystate database, which is tied to
the %city hash?
a. close ( citystate ) ;
b. unbind( %city) ;
c. untie ( $city) ;
d. untie ( %city ) ;

Muhammad Nawaz
Muhammad Nawaz
Numerade Educator
02:13

Problem 6

If the tie function does not contain the 0_CREAT flag, the number ______ is used in the function’s mode argument.
a. 0 (zero)
b. 1 (one)
c. 0666
d. None of the above.

Aman Gupta
Aman Gupta
Numerade Educator
02:32

Problem 7

The _________ module contains the definition of the 0_RD0NLY flag.
a. Fcntl
b. Fcntrl
c. Filectrl
d. Filecon

James Kiss
James Kiss
Numerade Educator
01:15

Problem 8

Which of the following statements removes the “Atlanta” key and its correspond¬
ing value from the citystate database, which is tied to the %city hash?
a. delete ( %city {Atlanta} ) ;
b. delete ( $city{Atlanta} ) ;
c. delete ( $citystate{Atlanta} ) ;
d. None of the above.

James Kiss
James Kiss
Numerade Educator
01:16

Problem 9

Which of the following statements concatenates the contents of the $first vari¬
able, a space, and the contents of the $last variable, and then assigns the result to
the $name variable?
a. $name = $first . " " . $last;
b. $name = $first & " " & $last;
c. $name = $first + " " + $last;
d. $name = $first, " " , $last;

Ernest Castorena
Ernest Castorena
Numerade Educator

Problem 10

When a database is tied to a hash, changes made to the hash are automatically reflected in the database.
a. true
b. false

Check back soon!
01:02

Problem 11

A collection of data that is stored in a disk file and organized so that its contents can be easily accessed, managed, and updated is called a ___________

Aditya Sood
Aditya Sood
Numerade Educator

Problem 12

Write a Perl statement that uses the tie function to open a DBM database named payroll. The statement should bind the database to a hash named %pay. The database should be opened for both reading and writing, and created if it
does not exist.

Check back soon!

Problem 13

Write the statement to add the “1234” key and the value “450.67” to the payroll database opened in Question 12.

Check back soon!
01:28

Problem 14

Write the statement to add the “2222” key and the value “500” to the payroll data¬base opened in Question 12.

James Kiss
James Kiss
Numerade Educator

Problem 15

Write the statement to delete the “1234” key and the value “450.67” from the payroll database opened in Question 12.

Check back soon!

Problem 16

Write the statement to increase, by 10%, the value corresponding to the “2222” key in the payroll database opened in Question 12.

Check back soon!
11:29

Problem 17

Write a selection structure that determines whether the payroll database opened in Question 12 contains the “1234” key. It it does, print the value corresponding to the key; otherwise, print the message “This key is not in the database.”

RO
Reynald Oliveria
Numerade Educator

Problem 18

Write a statement that closes the payroll database opened in Question 12.

Check back soon!

Problem 19

Assume that the $city, $state, and $zip variables contain the strings “Darien”, “IL”, and “60561”, respectively. Write a Perl statement that uses the variables and the concatenation operator to assign the string “Darien, IL 60561”
to the $address2 variable.

Check back soon!

Problem 20

The SDBM_File module saves the database information in two files. One file has a dir extension on its filename, and the other has a _______ extension.

Check back soon!