Generic perl golf rules (Version 1.01)

  1. The program must be written as one or more lines. The score for each hole is the total number of bytes you need (smaller is better). If your program is more than one line, you must count the newlines in between as one byte each. The #! line is not counted. If you use options on the #! line, the options themselves are counted, including the leading whitespace, the - and any trailing whitespace (but not the newline). Get the count program if you have any doubts.
  2. The program is expected to finish in a reasonable time. This means that even for your program's worst case input (whether that case is in the testset or not) the average runtime of your program should be less than the contest length, even on a somewhat slow computer (for discussion purposes we'll define this to be a 100Mhz Pentium II running a well optimized perl). The program also has to be valid only during the period that the challenge runs.
  3. The program is assumed to run on a perfect computer that never makes mistakes, and when the program finishes, the result should always be correct.
  4. You can submit as often as you want to until the deadline, no reason to wait until the last minute. In fact, other people want to see the score to beat on the leaderboard. So don't be a spoilsport by hoarding your score. Submit early and often.
  5. If teams are allowed (by default they are), you may only play in one team and not at the same time play as an individual. Teams may be extended during play, but not with people already playing. Teams should be clearly marked as such by having the word "team" in their name, e.g. "Alma Media Golf Team".
  6. The program may only use the perl executable, no other executables on the system are allowed (in particular, you must not use the programs implementing any other holes. The program may use itself though). You may use any of the perl 5.8.0 standard core modules. Your solution must be portable in the sense that it should work on all official unpatched versions of perl 5.8.0 everywhere. It's perfectly fine to abuse perl 5.8.0 bugs. For perl golf the executable (not the documentation) defines the language.
  7. Some golfs are played with the rule that you are not allowed to use any modules, even the standard core ones. However, there are some perl statements like the unicode regex /\pM/ that implicitly load a number of modules. You are still allowed to use code like that, but in a "no modules" contest you are not allowed to use the extra symbols that became available this way (like Carp::croak). Notice that perl also has builtin functions like utf8::downgrade that are available even if you don't load the utf8 module. These are always valid to use.
  8. The program should be self-contained (except for any I/O mentioned in the challenge). In particular, you may not do things like fetching extra data from a remote site.
  9. You may assume ASCII as character set and you may use perl's unicode semantics.
  10. Any bytes may be used in the sourcecode, including things like binary 0.
  11. At least 55% of the sourcecode must consist of normal ASCII characters matching /[ -~\t\n]/.
  12. All input and output will have a total size that will comfortably fit in memory (without swapping) and still allow you ample memory to play with.
  13. Your program should not introduce arbitrary limits not specifically mentioned in the challenge. In particular, your program should not need changes depending on the amount of free memory it runs with. E.g. doing @a = (1) x (10**8) (trying to create an array bigger than every valid inputsize) is wrong. It will fail miserably unless the machines has about 2 Gigabytes of free memory. You may however always assume enough base memory to make datastructures of a few million entries (or strings of a few million characters), so something like @a = (1) x (10**6) is just fine. Using the rule that the input fits in memory you can also see that @a = (1) x $input_size is OK (if the input is 10**8 bytes, that rule ensures that in that case you in fact have these Gigabytes of free memory).

    This rule is intentionally not formulated in terms of real memory, since that is too variable. But as a (non official) rule of the thumb: if your program uses more than a few tens of megabytes of memory, start thinking whether you can justify that.

  14. Since your program should work on all official versions of perl 5.8.0, it should work on both the 32-bit and 64-bit versions. This has a number of implications. Among them: Still, for most things the difference between 32-bit and 64-bit won't matter. You don't directly have to try to install both.
  15. The program will be called as
    some_perl_5.8.0_binary -- programname {args}
    The file programname will be non-executable, but readable and writable (in fact, on unix it will have permissions 644). You do not get to choose the programname, but it will match /^[a-zA-Z][\w.-]*\z/ and will be the initial value of $0. You also don't get to choose the name of the perl binary.
  16. If you have no options, you may leave out the #! line. If there is one, it will start with #!, and you may decide to follow that with an optional space or tab and a /. For the rest you only know that the part before any options will match m#^[\w/.-]+\z#, but you do not get to choose the exact path.
  17. STDIN, STDOUT and STDERR may or may not be files.
  18. If a read on a perl handle gives EOF (End Of File), you may assume later reads on the same handle will again EOF.
  19. If very late in the game an important new testcase gets added to the testsuite, the deadline should be extended so people have time change their solutions.
  20. The sort operator is stable in perl 5.8.0 (which means that elements that compare as equal among each other will appear in the output in the same order as in the input).
  21. Several things are not so much determined by perl itself, but by the environment in which it runs. But in real perls some things still tend to be true. Here are a number of assumptions you may make until someone finds a real perl (not specifically built to break them) that breaks them. Some of them may be even further restricted.