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
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