Random Code 9: Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# # Globals: # # Regex to match balanced [brackets]. See Friedl's # "Mastering Regular Expressions", 2nd Ed., pp. 328-331. my $g_nested_brackets; $g_nested_brackets = qr{ (?> # Atomic matching [^\[\]]+ # Anything other than brackets | \[ (??{ $g_nested_brackets }) # Recursive set of nested brackets \] )* }x; # Table of hash values for escaped characters: my %g_escape_table; foreach my $char (split //, '\\`*_{}[]()>#+-.!') { $g_escape_table{$char} = md5_hex($char); } # Global hashes, used by various utility routines my %g_urls; my %g_titles; my %g_html_blocks; # Used to track when we're inside an ordered or unordered list # (see _ProcessListItems() for details): my $g_list_level = 0; #### Blosxom plug-in interface ########################################## # Set $g_blosxom_use_meta to 1 to use Blosxom's meta plug-in to determine # which posts Markdown should process, using a "meta-markup: markdown" # header. If it's set to 0 (the default), Markdown will process all # entries. my $g_blosxom_use_meta = 0; sub start { 1; } sub story { my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; if ( (! $g_blosxom_use_meta) or (defined($meta::markup) and ($meta::markup =~ /^\s*markdown\s*$/i)) ){ $$body_ref = Markdown($$body_ref); } 1; } |
I’m a bit surprised that Perl is so low on the list of common languages in github. I’m guessing this is because people tend to use Perl for small projects, and not for large ones.
This impression is bolstered by the most-forked Perl project on github, Gitolite, which is not a lot of code. Actually, it’s more than I thought—it turns out that Perl files can end with ".pl" or ".pm", silly me.
Okay, more later.