Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

xsawyerx (8978)

  (email not shown publicly)

Journal of xsawyerx (8978)

Monday March 01, 2010
08:20 AM

Gaming FAIL

[ #40215 ]

original post can be found on my blog.

Many years ago, when I was... roughly 15 (I think), I met Theodor Ts'o (one of the first hardcore Linux Kernel hackers, since version 0.90, I believe) at a Linux event IBM organized in Israel. I should note that he is a very nice person.

After the event, we got to talk a bit. We talked about our favorite games. Mine was "avoiding segfaults". This was back when I was programming in C.

Today I wrote the following regex: qr/^([\w|\.]+)\s+(?(\d+)\s+)?(\w+)\s+(?:(\d+)\s+)?([\w|\d|\.]+)$/;

Then got a Segmentation fault

Can you spot the error?

Here's a hint: it is missing a colon (:).

This is perl, v5.10.0 built for i486-linux-gnu-thread-multi

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I don't get a SEGV. I get an error that answers your question:

    $ ~/Sandpit/5100/bin/perl5.10.0 -e 'qr/^([\w|\.]+)\s+(?(\d+)\s+)?(\w+)\s+(?:(\d+)\s+)?([\w|\d|\.]+)$/;'
    Unknown switch condition (?(\d in regex; marked by <-- HERE in m/^([\w|\.]+)\s+(?( <-- HERE \d+)\s+)?(\w+)\s+(?:(\d+)\s+)?([\w|\d|\.]+)$/ at -e line 1.

    And that's on This is perl, v5.10.0 built for i686-linux