perl + firearms + highschool student = trouble

David Waldo waldo at
Fri Mar 16 08:52:28 CST 2001

>From, beware of mistaken scalar context assignments ...

The big buzz in Perl today is a Slashdot post to the effect that a
couple of high school sophmores attracted the attention of their
school administrators, and eventually even the police, all thanks to
a little confusion over the difference between scalar and list
contexts in perl.

    # Scalar context assignment: Store the entire output of the well-known
    #     UNIX fortune(1) program.

    my $f   = `fortune`;

    ... is not the same as ...

    # List context assignment, with one element on the left side: Store
    #    *just the first line* of the output of fortune(1).

    my ($f) = `fortune`;

Apparently, the lad in question used the latter code to generate
random quotes on his webpage, rather than the former scala context
code, which is probably what he wanted. When school administrators
viewed the site, they got a page containing, among other things,
just the first line of a William Gibson quote mentioning smuggling
firearms, totally out of context and without attribution. The rest
of the story isn't hard to imagine, but you can read all about it at:

The article concludes by quoting from the Camel 3: "You will be
miserable until you learn the difference between scalar and list
context." Yeah, no kidding.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 2799 bytes
Desc: not available
Url :

More information about the Baltimore-pm mailing list