Perl code highlighters
2008/04/28 filed under /perlPerl can be a real mess, yes. Everyone knows it, a few try to disagree, but in the end, you can make Perl code look very cryptic. So maybe this post isn't really fair. Never the less, I'd like to point out an annoyance I have noticed for some time now.
All over the web, websites exist that allows you to dump some code. The website will highlight it accordingly to the chosen language. While this usually works fine, it fails a lot of times on the Perl variable $#. This special variable specifies the last index of a list. As you might guess, most highlighters see the hash and think: comment!
Let's use this code:
#!/usr/bin/perl
my @test = qw(Just another Perl Hacker);
print "Last index of the test list is:", $#test, "\n";
print "Oh, of course ... ", join " ", @test, "\n";
This is fairly easy code to follow, even for a non-Perl programmer, I believe, so it's up to you to figure out what it does ;-)
Now, let's see how a 10 random sites handle this:
Wrong (see the hash as a commenting prefix):
- hashbin.com
- nopaste.info
- paste.linode.com
- paste2.org
- pastebin.ca
- pastebin.osuosl.org
- privatepaste.com
- rafb.net
Correct:
Sad but true ...



Comments