Chapter 32. The Second Perl/Internet Quiz Show

Jon Orwant

At O’Reilly’s 1999 Open Source conference, I emceed and judged the Second Perl/Internet Quiz show, which pitted teams of Perl hackers against one another to win enduring fame and a motley collection of prizes. Here are the questions, including a few I didn’t ask.

Four teams played, with all participants winning one of the following:

  • VA Linux: A cube fridge and $40 to fill it with junk food

  • perltoys.com: Magnetic Perl Poetry Kits

  • Geek Cruises: 50% off a state room for the Perl Whirl Alaska Tour

  • O’Reilly $50 and $25 gift certificates

  • TPJ: Free two-year subscriptions

If you want to tally your score, you can use the ratings at the beginning of Chapter 31.

Sample Questions

The Perl Quiz Show isn’t like Jeopardy or Win Ben Stein’s Money. It’s modeled after College Bowl, a family of collegiate tournaments that I participated in at MIT. Here’s the sample toss-up I used to warm up the teams, with interspersed commentary.

Toss-up 0: This company started in a abarn in Newton, Massachusetts,

This question illustrates how the ideal toss-up question is written: with the most obscure information at the beginning.

and originally specialized in technical writing and consulting.

At this point, a few people in the crowd already knew the answer.

Their consulting business slowed down in 1985, so they tried publishing some of their material as books, and thought they might give them away to promote their consulting business.

Most people had a good guess after this question.

In 1988, they were mobbed by participants at the MIT X Conference for their Xlib manuals, and soon after they focused on publishing computer books.

Now just about everyone knew.

They now publish more than 120 books, many of which have pictures of animals on the cover.

If you haven’t buzzed in by now, you shouldn’t be playing.

They’ve recently branched out into the conference business.

And the kilowatt spotlight over the head:

For ten points, name this company that is hosting the conference YOU’RE AT RIGHT NOW.

Answer: O’REILLY & Associates

Because many toss-ups are designed with a giveaway at the end, the questions aren’t as challenging in print as they are when spoken. Remember that when you read these questions: the skill is not in answering the question correctly so much as answering it before the other team.

The capitalization indicates the essential part of the answer that players had to utter. Here, anyone who buzzed in only had to say “O’Reilly”; they didn’t have to give the full name of the company.

Here’s a sample bonus question:

Bonus 0: I’ll give you four book titles; you tell me whether O’Reilly published the book or not.

Occasionally, a bonus question is linked to the previous toss-up.

a. Using Samba

Answer: YES. That’s an easy one.

b. The Adventure of Food

Answer: YES. Surprisingly, the team got this one right.

c. Danger!

Answer: YES. Sounds like a dime-store detective novel.

d. Curious George Learns Assembler

Answer: NO.

Toss-up Questions

Toss-up 1: Movies have their Oscars, music has Grammys, and TV has Emmys. This year, the Internet Movie Database (imdb.com) won this award, which is given to web sites.

Toss-up 2: This hybrid data structure is available in Perl 5.005, allowing you to refer to array elements with names instead of numbers.

Toss-up 3: This newspaper has many more web visitors than actual paper subscribers, and has run stories entitled “Bill Gates Grants Self 18 Dexterity, 20 Charisma,” “Chess Supercomputer Beaten Up By More Popular Computer,” “Microsoft Patents Ones, Zeros,” “Apple Employee Fired For Thinking Different,” and “New Smokable Nicotine Sticks.” What is this newspaper named after a spherical vegetable?

Toss-up 4: Guess that special variable. What magic scalar can you undefine to make Perl read an entire file directly into a single string?

Toss-up 5: The baud rate of regular fax machines is a common modem speed, although slow by today’s standards. Name this speed.

Toss-up 6: There are many sorting algorithms; Perl uses this variety. What is it?

Toss-up 7: His relevance to Perl is somewhat obscure: the Perl source code is full of Tolkein quotes, and he is the director of the Lord of the Rings trilogy, shot on location in New Zealand. Some of his other movies are Bad Taste, Meet the Feebles, and Dead Alive.

Toss-up 8: You can use it with Active Server Pages and the Windows Scripting Host. This package is an ActiveX scripting engine that lets you incorporate Perl into any ActiveX scripting host. Name it.

Toss-up 9: It had both modules and classes back in 1977. Every official module had an identifier: one or two letters followed by a single digit, and a name, such as White Plume Mountain, the Village of Hommlet, and Glacial Rift of the Frost Giant Jarl. Some of the classes were fighter, thief, cleric, and magic-user. Name this game.

Linked Bonus. The game came with five types of dice: 4-sided, 6-sided, 8-sided, 12-sided, and 20-sided. I’ll give you a situation, you tell me which die is used in it.

  1. Determining your character’s strength, intelligence, wisdom, dexterity, constitution, and charisma.

  2. How many hit points a first-level magic user has.

  3. You’re hit by lightning and need to make a saving throw.

  4. How many hit points a first-level cleric has.

Toss-up 10: What does this print?

#!/usr/bin/perl
use constant e => 2, pi => 3;
print e ** pi;

Toss-up 11: If Larry Wall is the father of Perl, and Perl is the mother of the World Wide Web, and the Internet is the father of the World Wide Web, the Web is the sister of FTP, and Al Gore is the grandfather of the National Organ Transplant Act, what relation is FTP to the National Organ Transplant Act?

Toss-up 12: Perl doesn’t have any Year 2000 bugs, but if you store the Unix time in a 32-bit integer, you’ll wraparound to 0 in what year?

Toss-up 13: What will this print? You can provide your answer in exponential notation if you wish.

print (1 << (1 << 5))

Toss-up 14: A computer utilizing this medium was used to solve the Traveling Salesman Problem in 1995 by executing 100 trillion operations per second, 100 times faster than the fastest supercomputer of the day. This medium let the computer perform 20 quintillion operations for every joule of energy, and was able to store one bit per cubic nanometer, which is one trillion times the storage density of videotape. What is this medium, best known for its double helix?

Toss-up 15: Guess that scalar. Name the scalar that holds the time when your program began running.

Toss-up 16: (Tiebreaker; not asked.) Guess that operator: if you stick this operator in between $x and $y, it will set $x to $y unless $x is already true.

Toss-up 17: This country has the highest number of Internet hosts per capita, and the CPAN master site is located there. On a clear day you can see Estonia from its tallest building, which is a mere twelve stories high. Linux started there.

Toss-up 18: Guess that module. It has Purity, Terse, and Deepcopy methods. It’s bundled with Perl, and written by Gurusamy Sarathy. It’s most commonly used to pretty print complex data structures via its Dumper method.

Toss-up 19: The last meeting of this group was in Oslo, and at some of their workshops, they use humming to vote on proposals. Their motto is “Rough consensus and running code,” and they’re charged with maintaining the RFC Internet standards.

Toss-up 20: This character can be used as a shorter equivalent of the double colon. What is this character, whose string quoting behavior is emulated by the q function?

Toss-up 21: In 1995, Perl won the Nobel prize in this discipline, in part for discovering the tau lepton in the mid 1970’s. Name this discipline.

Toss-up 22: What will this print?

my $i; if ($i = 6) { print "success" } else { print "failure" }

Toss-up 23: You’re Gordon Freeman, a scientist in this popular computer game. After an explosion nearly destroys the underground plant you work in, you have to restart various machines and kill various aliens. Your fellow scientists are eager to be rescued by Marines until the Marines start massacring them in an attempt to cover up the aliens’ existence. What is this game, which has the same name as a term having to do with radioactive decay?

Toss-up 24: You want Perl to make use of an already existing C library. What utility is commonly used to create a stub interface?

Toss-up 25: The Netcraft web server survey has been compiled every August since 1995. In this year’s survey, these two web servers place first and second in terms of popularity percentages. What are they, in order?

Toss-up 26: In my opinion, the scariest addition to regular expressions in 5.005 is (?{ something }). Tell me what this does.

Toss-up 27: Hit your buzzer now.

Toss-up 28: New in 5.004, this pragma accounts for the fact that not every language uses a period as a decimal point, and that not every language has the same letters as English. Its name is related to L10N, which stands for “localization.”

Toss-up 29: “It is dark in here.” “The door is closed.” “The Diet Coke can is 41 degrees Fahrenheit.” So reads the web page for this device hooked up to the Internet. The device itself is at 48 degrees, and its freezer compartment is 12 degrees.

Toss-up 30: Where is the Internet top level domain .to located?

Toss-up 31: travesty, server, client, who, findtar, rmfrom, wrapsuid, uudecode, rename. These are all programs in what directory of the Perl distribution?

Toss-up 32: Two words, pronounced the same. One word is a U.S. army rank, the other is the name for the core of an operation system, and is also what you find plenty of on corn on the cob.

Linked Bonus: Microkernels versus monolithic kernels. (Here, I spoke off the cuff about the difference between the two.) I’ll give you four operating systems, and you tell me whether it has a monolithic kernel or a microkernel.

  1. MS-DOS

  2. GNU Hurd

  3. Linux

  4. NT

Toss-up 33: Guess that scalar. By default, out-of-memory errors aren’t trappable. But they can be if your Perl was compiled with PERL_EMERGENCY_SBRK and you create an emergency memory pool with this scalar, which has a caret followed by the thirteenth letter of the alphabet.

Toss-up 34: According to searchwords.com, this is the most popular search term. Surprisingly, it’s not pornographic, but is instead a popular audio format. Name this format, whose name is derived from MPEG3.

Toss-up 35: If you turn on warnings with -w, what error do you get if your Perl statement is nothing more than a plain string?

Toss-up 36: Pencil and paper ready: According to Win Treese’s Internet Index, there are 7.6 billion commercial email messages sent every day. If each message were a regular snail mail letter paying U.S. first class rates, tell me how much that would cost per year, within ten percent.

Toss-up 37: Guess that scalar. You could use it to cope with division by zero errors, because this variable contains the error message from the last eval command. Name this variable.

Toss-up 38: U.S. Senator Jon Kyl introduced a bill known as the Internet Prohibition Act in 1997. The act makes it a crime to perform this activity online, even though you can do it on Indian reservations and in Nevada. What is this activity?

Toss-up 39: Perl almost always ignores your comments. Name something that you can put in your comments that Perl will pay attention to.

Toss-up 40: According to the 9/12/97 issue of the Wall Street Journal, this is the number of miles of undersea cable. It’s a funny number, because light could travel it in almost exactly one second.

Toss-up 41: In Unix, Ctrl-Z suspends a process; Ctrl-C interrupts a process. You can keep these from happening in your Perl program with signal handlers. Give me the signal handler that lets you trap either Ctrl-Z or Ctrl-C.

Toss-up 42: Pick the most appropriate unit: days, weeks, months, or years. If you have a cable modem that gives you a constant 1.5 megabit downstream rate, how long would it take you to download the Library of Congress, compressed?

Toss-up 43: Guess that scalar. This scalar is true if you’re inside an eval and false otherwise. Name this serpentine scalar.

Toss-up 44: Marvin Minsky and Seymour Papert wrote a disparaging book about these computational entities and single-handedly quashed neural net research for almost two decades. What is the name of this single-layer neural network?

Toss-up 45: On August 16, 1999, they announced plans to provide Virtual Private Network (or VPN) support for their 594 series of network controllers. They specialize in IP connectivity with product lines that include remote access servers and switches for Ethernet and token ring LAN’s, terminal servers and serial connectivity products for Unix and NT platforms, and network controllers for IBM AS/400s. They trade on the Toronto Stock Exchange under the symbol PL, and trade on the NASDAQ under the symbol PERL.

Toss-up 46: What does close do if you don’t provide a filehandle to close?

Bonus Questions

Remember, bonus questions are typically tougher, because the entire team gets to confer before giving an answer.

Bonus 1: This is the first bonus of the game, so let’s have a question about beginnings. What regular expression metacharacter matches the actual beginning of the string? It’s not the caret, since that matches the beginning of each line, and in a multiline string it’ll match multiple times. The metacharacter I’m looking for matches only the very beginning.

Bonus 2: You can specify the background color of a web page with the BGCOLOR attribute of the BODY tag. If you set BGCOLOR to a pound sign followed by six hex digits, the first two indicate the amount of red, the second two indicate the amount of green, and the third two indicate the amount of blue. For instance, 00FF00 is a saturated green, and FFFFFF is white. Give me a good yellow.

Bonus 3: This special variable holds the name of your Perl program. On some operating systems, you can set it, and make your program seem like it’s named something else. Give me the short name of the variable, and the long name provided by the English module.

Bonus 4: A correctly functioning Perl program ends with the following two lines.

}BEGIN{
        @ARGV=<*M*>

These lines are not part of a string. “Here” documents don’t come into play, and there are no sneaky eval tricks. There are no funky characters after these two lines, nor is there a _ _DATA_ _ or _ _END_ _ previously. The program has no signal handlers, it does not launch another process, and it doesn’t make strange use of symbol tables or otherwise play with itself. The program does not use any module or pragma.

These two lines are executed just fine. If you put a print before or after the @ARGV line, it’s executed too.

What’s the simplest explanation?

Bonus 5: There’s a freeware porn detector that spiders through the web and flags an image as pornographic if the amount of continuous skin tone exceeds this threshold, expressed as a percent. As it turns out, this is the exact same threshold that Perl uses to determine whether a file is binary or text for the -B and -T flags. If more than this percentage of the characters are “odd characters” (like control characters or characters with the eighth bit set), it’s deemed a binary file. Name this amount, within ten percentage points.

Bonus 6: Give me the two reasons why laptop CPU speeds are typically slower than desktop CPU speeds.

Bonus 7: Describe what this displays:

print scalar(localtime);

Bonus 8: According to the St. Petersburg Times, in what year is the U.S. expected to use the Internet to collect Census data?

Bonus 9: Name that command-line switch.

  1. You’d use this switch to execute a Perl program in a larger message, because it tells the interpreter to skip down until it finds the first line beginning with #! and containing the word perl.

  2. You’d use this to append a newline automatically to every print statement.

  3. You’d use this switch to verify that your Perl program is syntactically correct.

  4. You’d use this switch to specify a directory where modules are located.

Bonus 10: Netcraft compiles an annual web server survey, and compiles its results by polling every server it can find, worldwide. Within a factor of two, how many sites was that, for the 1999 survey?

Bonus 11: This is a bonus in five parts; as soon as you get one wrong, the question is over. If the derived class Rabbit inherits from the base class Rodent and you invoke Rabbit::Forage, what subroutine does Perl look for next? (This question doesn’t work so well in print, since each subquestion gives away the answer to the previous subquestion.)

  1. After failing to find it in the Rabbit class?

  2. After failing to find it in the Rodent class?

  3. After failing to find it in UNIVERSAL?

  4. After failing to find a Rabbit::AUTOLOAD?

  5. After failing to find a Rodent::AUTOLOAD?

Bonus 12: I’ll describe five pairs of built-in Perl functions. The last letters of the first function are the first letters of the second function: you mash them together and give me the combined name. For instance, if I say “the function that adds something to the end of an array” and “the function that adds something to the beginning of an array,” you’d say “pushift.” The “sh” is shared.

  1. The function that removes something form the end of an array, and the function that readies a directory for reading.

  2. The function that converts a binary structure into regular Perl variables, and the function that declares a global namespace.

  3. The function that displays a formatted record, and the function that reports where a file pointer is.

  4. The function that clears all variables beginning with a specified letter, and the function that you’d use to keep your server from hanging onto a port after it’s no longer used.

  5. Finally, what two single-letter built-in functions combine to make a third built-in function?

Bonus 13: Tell me whether these statements about DBI, the Database Interface, are true or false.

  1. Both ODBC and DBI provide a generic interface to multiple database engines.

  2. DBI supports multi-threading.

  3. DBI runs on Windows 95.

  4. You can manipulate Microsoft Access database from DBI.

Bonus 14: Guess that module. I’ll name five modules that might exist on CPAN; you tell me whether they do.

  1. Net::Video

  2. WWW::Robot

  3. Games::WordFind

  4. Modem::Dial

  5. Tie::BikePower

Bonus 15: What does this do?

goto (qw(alpha beta gamma))[rand 3];

The rest of the question requires audience participation. I contend that goto is used far more often than people admit. I’ll ask the crowd to applaud if they’ve used goto in the last month, and then if they’ve used redo in the last month. Tell me whether the amount of applause will be significantly higher for goto, significantly higher for redo, or about the same.

Bonus 16: What country has the largest number of top-level domains ending in its two-letter country code? Hint: it’s not the U.S., since there aren’t that many .us domains.

Bonus 17: There are four steps to building and installing a CPAN module on a Unix system once you’ve downloaded and unpacked it. What are the four steps? Each step is something you type at the command line.

Bonus 18: What CGI environment variable can you use to determine which browser is visiting your pages?

Bonus 19: To the nearest ten percent, what proportion of Internet users use English as their primary language, according to a survey by Global Reach?

Bonus 20: I’ll give you four Perl constructs; you tell me whether they’re executed at run-time or compile-time when they appear by themselves in Perl programs.

  1. require statements

  2. BEGIN blocks

  3. use statements

  4. srand

Bonus 21: Here’s a palindromic program; it reads the same backwards as forwards. What will it display?

print $;,(1 => "able was i ere i saw elba" <= 1),;$ tnirp

Bonus 22: Which of these HTTP status constants exist? Tell me yes or no for each.

  1. HTTP_NOT_FOUND

  2. HTTP_GONE

  3. HTTP_PAYMENT_REQUIRED

  4. HTTP_TOO_MANY_USERS

  5. HTTP_LANGUAGE

Finally, what is the numeric HTTP status code for HTTP_NOT_FOUND?

Bonus 23: Name two ways to embed comments in regular expressions.

Bonus 24: Tell me whether the following snippets are legal or illegal.

  1. sub _ { print 4 }

  2. $$ = 17;

  3. if (2 < 3 < 4) { print

  4. open (M, “mail [email protected]”); print M, “Release Mitnick || die!”;

Bonus 25: You have a function that accepts either one or two arrays, and you want those arrays to be implicitly passed by reference. That is, if you’re passing in @red and @blue, you want the advantages of passing by reference but you don’t want to have to include the backslashes. What prototype should you use?

Bonus 26: Four languages: ADA, Basic Plus, C, and Fortran. I’ll give you four Perl features; you tell me which of the four languages it also appears in.

  1. ++ and --

  2. **

  3. ::

  4. … if

Bonus 27: What are the three types of System V IPC structures?

Bonus 28: What meaningful difference, if any, is there between how these two function invocations pass arguments to the blork subroutine?

blork();
&blork;

Bonus 29: I’ll give you five built-in Perl functions; you tell me the maximum number of arguments it accepts. I’m counting lists and expressions as single arguments, so for instance push takes two arguments: an array and a list.

  1. open

  2. tie

  3. substr

  4. splice

  5. split

Bonus 30: Perl programmers love their weird symbols. I’ll give you four esoteric symbol names; you tell me a more common name for that character. For instance, if I say “ampersand,” you’d say “and.”

  1. Octothorpe

  2. Solidus

  3. Quadrathorpe

  4. Pilcrow

  5. Lemniscate

Bonus 31: Perl has a somewhat unearned reputation for being hard to read. We can all show how clear it can be by writing lucid programs. But we could also show how murky it isn’t by comparing it to something worse. There’s a language called Befunge that is two-dimensional, with a stack and an instruction pointer that moves character by character through the program. Here’s a program that prints “Hello, world.”

0".dlrow , olleH">v
                 ,:
                 ^_@

At this point, I explained how Befunge worked. Full details are at http://directory.google.com/Top/Computers/Programming/Languages/Befunge/, but you can get the gist of it from the vcharacter. In the program above, the characters are processed from left to right (pushed down on an instruction stack) until that vis encountered. Then the characters are processed from top to bottom, until _is encountered. _is a “horizontal if,” which sends control to the right or the left depending on the contents of the stack.

What will this print?

      v,<
0"lreP">^
      +
      +
    >v"
    ^,_@
      @

Bonus 32: Answer the question posed by this visual code snippet:

#!perl
# What does this print?

seek(DATA, 7, 0);
print scalar <DATA>;

__END__
This is
some test
data for
your program's
end.

Bonus 33: This HTTP header field is used by a browser to avoid downloading a web page that is already in its cache. The web server compares the value of this field to the last time the web page changed, and returns it only if the web page is more recent. Name the field.

Bonus 34: What does this print? I’ll give you some extra time.

perl -e "print substr(**.**, 7, 2)"

Bonus 35: XML documents often have associated DTDs, or document type definitions. I’ll give you four DTDs, you tell me if they exist in any of the big DTD repositories on the Net.

  1. Music Markup Language

  2. HTML

  3. News stories

  4. Real estate listings

Bonus 36: What does the following print?

perl -wle 'print +(8/2).".".0.0.0'
  1. 4

  2. 4.

  3. 4.0

  4. 4.00

  5. 4.000

  6. 4.0.0.0

Bonus 37: I’m going to give you some Perl features. Tell me which version of Perl added it: 1, 2, 3, 4, or 5.

  1. The ability to handle binary data in strings

  2. Henry Spencer’s regular expression package

  3. Support for object-oriented programming

  4. The ampersand before function names became optional

The Answers

As with the previous quiz, the mandatory part of the answer is given in capital letters.

Toss-up Answers

T1. WEBBY. Not one, but two recipients held their trophy aloft and declared, in an embarrassing imitation of Titanic director Jim Cameron, “I’m the king of the World…Wide Web!”

T2. PSEUDOHASH

T3. The ONION

T4. $/ or $INPUT_RECORD_SEPARATOR. (It’s a single newline by default. If you set it to the empty string, Perl will read your file in as paragraphs.)

T5. 9600 baud

T6. QUICKSORT

T7. Peter JACKSON

T8. PERLSCRIPT

T9. DUNGEONS AND DRAGONS.

T10. 1. (pi is undefined because use constant only accepts a single assignment. For extra credit, try to prove which is greater, e to the pi’th power, or pi to the e’th power, without resorting to a computer or calculator.)

T11. FIRST COUSINS (This assumes that Gore is father of the Internet. In his defense, he never actually claimed to be.)

T12. 2038

T13. 0.1 << 5 is 32, so the whole expression is 2 to the 32. Even though you can print 2 ** 32 just fine, Perl uses 32-bit integers when you’re bit shifting, so the ones get shifted off the left end into oblivion.

T14. DNA. (The work was done by Len Adleman, who’s the A of RSA.)

T15. $^T or $BASETIME

T16. ||=

T17. FINLAND or SUOMI. (Source: Win Treese’s Internet Index.)

T18. DATA::DUMPER

T19. IETF or INTERNET ENGINEERING TASK FORCE

T20. APOSTROPHE (’). (You can even say use LWP’Simple, but that looks screwy because when Perl 5 introduced use it also introduced the double colon syntax.)

T21. PHYSICS, won by Martin Perl. (The tau lepton is identical to the electron, but weighs 3,500 times as much and survives less than a trillionth of a second. According to the Standard Model of particle physics, the elementary building blocks of matter appear in families, with two leptons and two quarks in each. The tau lepton is the first-known member of a third family. The other members are the bottom and top quarks.)

T22. SUCCESS. (That = should be ==.)

T23. HALF-LIFE. (Someone about five or six rows back must have been a huge Half-Life fan, because he went absolutely spastic as I read the question.)

T24. H2XS. (See the perlxstut documentation for more information.)

T25. APACHE and MICROSOFT. (Apache had 55% and Microsoft had 22%. Netscape was third with 7%.)

T26. It executes CODE or EVALuates code.

T27. (Who says Perl programmers don’t care about speed?)

T28. The LOCALE pragma. (See the perllocale documentation bundled with Perl for more information.)

T29. REFRIGERATOR. (From the FAQ at http://www.hamjudo.com/cgi-bin/refrigerator: The Coke can is colder than the fridge itself because it’s on the top shelf near the coils. People always assume that fridge temperatures are uniform, but that’s never the case.)

T30. TONGA

T31. EG or EXEMPLI GRATIA. (This directory is no longer part of the Perl distribution.)

T32. KERNEL

T32-Bonus. MONO, MICRO, MONO, MICRO

T33. $^M

T34. MP3. (“pokemon” was number 6.)

T35. USELESS USE OF A CONSTANT in void context. (Mark Jason Dominus said: “The numbers 0 and 1 are exempt from this warning. I looked in the source code, and discovered three other exemptions: Strings beginning with ‘di’,‘ds’, or ‘ig’ do not trigger this warning.” These exceptions were for the benefit of the wrapman program. They allowed you to include documentation in Perl programs—the pod format hadn’t been invented yet—and feed the programs to either Perl for execution or nroff for documentation.)

T36. $915.42 BILLION. (Accept between $823.878 BILLION and $1.006962 TRILLION)

T37. $@ or $EVAL_ERROR

T38. GAMBLING. (The Kyl bill also makes it a crime to provide information about how to use the Internet for gambling. The Senate passed it 90–10, and it’s now languishing in a House committee. By the way, several members of the U.S. Supreme Court have a regular poker game.)

T39. The LINE directive.

# line 300 "camel"
die;

Died at camel line 300.

T40. 186,000 (Only three significant digits required.)

T41. $SIG{TSTP} or $SIG{INT}.

T42. YEARS. (About four of them). The Library of Congress has about 20 terabytes (160 terabits) today.

T43. $^S

T44. PERCEPTRON

T45. PERLE systems, named after CEO Joseph Perle. (Correct spelling not necessary.)

T46. It closes the CURRENTly selected FILEHANDLE. (That’s usually STDOUT.)

B1. A

B2. FFFF00 (Or something close to it; FFFF66 looks pretty good too. The red and green values need to be close to each other and nearly maxed out; blue should be anywhere from 00 to 88. During the quiz show, I showed pictures of the resulting colors.)

B3. $0 and $PROGRAM_NAME

B4. The Perl program used the -n or -p flags. When the documentation says that they wrap a loop around your code, it means that literally: Perl provides the opening and closing braces that make this program syntactically correct. (This trick is used in Chapter 46.)

B5. 30% (accept from 20% to 40%)

B6. HEAT dissipation and POWER consumption. (The Boston.pm team got both answers correct; impressive for such a poorly-worded question.)

B7. The current date and time in English.

B8. 2010. (Lisa Nyman is a frequent Perl conference attendee who hacks Perl for the U.S. Census. As I’d hoped, she was in the audience; I could tell, because she yelled out “WRONG!” as soon as I read the answer. Turns out that the Census will be accepting some online forms for the 2000 Census as a test. The team answered 2010, so I awarded full credit. If memory serves, the team was all Norwegian, so after posing the question I added that the U.S. census happens every decade on the decade.)

B9. -x, -l, -c, -I

B10. 7,078,194. Accept between 3,539,097 and 14,156,388.

B11. Perl looks in: a) RODENT::Forage, b) UNIVERSAL::Forage, c) RABBIT::AUTOLOAD, d) RODENT::AUTOLOAD, e) UNIVERSAL::AUTOLOAD. After that, you could say it looks in $SIG{_ _DIE_ _}.

B12. POPENDIR, UNPACKAGE, WRITELL, RESETSOCKOPT, M, and Y

B13. TRUE, FALSE, TRUE (there’s also a Win32::ODBC module), TRUE (you use the DBD::ODBC module)

B14. NO, YES, YES, NO—although there is a Win32::Serial module, YES (Tie::BikePower calculates power output and power consumption for bicycling. You give it things like riding speed, body weight, hill grade, and wind speed, and it shows you your power output and consumption.)

B15. Jumps to one of the three labels alpha, beta, and gamma at random. (FORTRAN also lets you compute gotos. For the audience participation question, the applause levels were about the same.)

B16. GERMANY. (The top four are shown below. There are 9.2 million registered domains, depending on who’s paid their Internic fees this week. 5.5 million are .com sites.)

.de (Germany)                        391,113
.uk (United Kingdom)                 360,821
.au (Australia)                      122,201
.dk (Denmark)                         93,181

B17. perl Makefile.PL, make, make test, make install

B18. HTTP_USER_AGENT

B19. SIXTY percent. (Accept between FIFTY and SEVENTY.) European non-English, 25.5%; Asian languages, 15.5%.

B20. RUN, COMPILE, COMPILE, RUN.

B21. 11. ($; is chr(28), => is a comma, a string evaluates to zero in a numeric context, and the next comma is followed by a null argument to print. $ is a no-op, and tnirp is a bareword.)

B22. YES, YES (it means that the document has been permanently removed), YES, NO, NO, 404.

B23. The /x modifier and (?#comment)

B24. LEGAL, LEGAL but ineffective, ILLEGAL, ILLEGAL. (It’s illegal to threaten the president, and there’s a comma after the filehandle in the print statement. There’s also no pipe symbol before mail, and the @ isn’t backslashed. Whoever wrote this should be in prison.)

B25. @;@ (Tom Christiansen pointed out that prototypes should really be called “input context templates,” because they’re really not like prototypes in other languages.)

B26. C, FORTRAN, ADA, BASIC Plus

B27. SEMAPHORES, MESSAGE QUEUES, and SHARED MEMORY.

B28. blork() has no input arguments; &blork ends up with the input arguments from its caller.

B29. 2 (filehandle, expression. You can omit the expression!), 3 (variable, classname, list), 4 (expression, offset, length, replacement), 4 (array, offset, length, list), 3 (pattern, expression, limit).

B30. POUND or HASH or TICTACTOE, SLASH (it’s also called a “virgule”), EQUAL sign (two quadrathorpes form an octothorpe), PARAGRAPH symbol, INFINITY symbol.

B31. P+e (This was inspired by Chris Howe’s entry for the Obfuscated Perl Contest in Chapter 46, which printed out “The Perl Journal” by creating a Befunge interpreter and running a Befunge program that printed “The Perl Journal” through it. He did this in exactly 1,000 characters.)

B32. # WHAT DOES THIS PRINT? (Seeking the DATA filehandle can take you anywhere in the program. Nathan Torkington pointed out that you can even stat(DATA) to find out when the program was last modified.)

B33. IF-MODIFIED-SINCE

B34. **. (**.** looks like a shell glob, but it’s actually a ** typeglob. ** is *main::*, so **.** is *main::**main::*, and the eighth and ninth characters of that are **.)

B35. YES, YES (HTML 4.0), YES, YES

B36. 4.00 (The subexpression 0.0.0 is actually the float 0.0 concatenated with 0. But 0.0 is the same as 0, hence we only get 2 0’s.)

B37. 3, 2, 5, 5.

Thanks to Tom Christiansen, Chris Nandor, Abigail, Mark Jason Dominus, Nathan Torkington, and Jarkko Hietaniemi, all of whom provided a few question ideas (sometimes inadvertently).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset