This snippet will calculate your official perl golf score. It comfoms to the standard set down in RFC foobar with the baz ammendments. In short this standard specifies that we count the chars from (but not including) the subs opening curly up to (but not including) the closing curly. Leading/trailing whitespace and newlines are not counted.
package GOLF; use strict; my $code = <<'CODE'; # paste code in here CODE $code =~ s/^\s+|\s+$//gm; $code =~ s/\n//g; $code =~ s/}$//; $code =~ s/^sub\s+(\w+)\s*{//; printf "Length of sub '$1' => %d chars\n", length $code;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Official GOLF score
by cforde (Monk) on Jul 12, 2001 at 00:33 UTC |