I'm going to lose at golf, but it taught me an important lesson about the subtleties of reverse()
. Perl in way too many (142) characters:
#!/usr/bin/perl
$_='#!/usr/bin/perlc%$_=c%s%c%;print sprintf~~reverse,10,39,~~reverse,39,10;c%';print sprintf~~reverse,10,39,~~reverse,39,10;
This proves that the sprintf()
/reverse()
combination is not the way to approach this problem. A better Perl solution will undoubtedly use eval()
.
Vast improvement: 45 characters:
print~~reverse <<''x2
print~~reverse <<''x2
Note that the source file should end in a blank line. The blank line is counted in the character count - how else do you think we got an odd character count out of two identical lines of code?