Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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 use.perl.org'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)"}}}


Comment on Re: The Perl Review
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://143355]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-08-27 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (253 votes), past polls