Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: The Perl Review

by Koschei (Monk)
on Feb 05, 2002 at 04:46 UTC ( #143355=note: print w/replies, xml ) Need Help??

in reply to The Perl Review

An amusing little test suite. The assorted strings in q!! are various peoples golf attempts from here and's article.
#!/usr/bin/perl -w use Test::More qw/no_plan/; use strict; my%v=( '1' => 1, '4' => 4, 'A' => 10, '0' => 'zero', 'B' => 11, 'Z' => 35, 'AA' => 370, '1F' => 51, '03F' => 3*36+15, 'BF' => 11*36+15, '2B3F' => 107691, ); foreach my$g( q!y/0-9A-Z/\0-#/;($a*=36)+=ord for/./g;$a! , q!map{$t+=(ord()-(/\d/?48:55))*36**$l++}reverse split//,pop;$t! , q!map{$t+=(ord()-(/\d/?48:55))*36**$l++}reverse split//,shift;$t! +, q!$a+=$_*36**$b++for reverse map/\d/?$_:ord($_)-55,pop=~/./g;$a! , q!($_,$s)=@_;y/A-Z/:-T/;$s=36*$s-48+ord for/./g;$s! , q!y/A-Z/:-T/;$a=36*$a-48+ord for/./g;$a! , q!$a+=(-55+/\d/*7+ord)*36**$b++while$_=chop$ARGV[0];$a! , q![map$a+=(/\d/?$_:-55+ord)*36**$b++,reverse pop=~/./g]->[-1]! , q!$n=ord(pop);$a=($n>>6)?(($n&31)+9):($n&15);! , q!eval join"+",map{$_=(-55+ord uc);$_+=6if/-/;"$_*36**".$i++}rever +se split('');!, q!map$d=$d*36+(/\d/?$_:-55+ord),pop=~/./g;$d! , q!$b=$b*36-48-7*/\D/+ord for pop=~/./g;$b! , q!sub x{$_&&-7*/\D$/+ord(chop)-48+36*&x}x$_! , #q!$n=pop;for(;$n ne((0..9),(A..Z))[$a];$a++){}"$a"||0;! , ){while(my($i,$n)=each%v){my$o=eval"package G;no strict;no warnings;\@ +A". "RGV=\@_=(\$_='$i');do{$g}||'zero';"or die$@;delete $::{'G::'};if(defi +ned $o){ok($o eq$n,sprintf("| %-4s -> %-6s == %-6s (length %3d) [%s]",$i,$ +o, $n,length $g,$g))}else{fail "Return value undefined ($g)"}}}

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://143355]
[erix]: heh, I like the "Resolved" (Christiansen is really funny)
Discipulus is makita a reincarnation of grinder?
[erix]: I probably also need to understand TAP a bit better than I do
[Corion]: Discipulus: Hahaha ;)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-03-23 08:33 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (285 votes). Check out past polls.