Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

ASCII art maker

by thomas895 (Chaplain)
on Dec 24, 2011 at 21:56 UTC ( #945043=obfuscated: print w/replies, xml ) Need Help??

Albeit very simple, I thought I'd share.

#!/usr/bin/perl my%cd=reverse('a'=>'$','='=>'5','7'=>"'",'d'=>'1',','=>'%','2'=>'r','y +'=>'(','1'=>')','"'=>'3','t'=>'@','e'=>'{','>'=>'4','s'=>'n',"\n"=>'h +','c'=>'"','('=>' ','$'=>';','\\'=>'c','r'=>'d', ':'=>'9','h'=>"\n",'.'=>',','@'=>'t','['=>'\\',';'=>':','f'=>'m','i'=> +'}','n'=>'y',' '=>'s','{'=>'>',']'=>'l','3'=>'[','%'=>'o','9'=>'f','m +'=>'=','_'=>']','l'=>'a','4'=>'2','p'=>'.', ')'=>'e',"'"=>'i','}'=>'7','5'=>'_','o'=>'p');my$r='';while(<DATA>){$r +.=$_;}my$p='';foreach(split("",$r)){$p.=$cd{$_};}chop$p;eval($p)and(p +rint($@)); __DATA__ =(s;" $ds5sioi:h=(s;1{mss5s\hssss\s3n9_3%s3"9)3%s3y9)3sl%hssss\s3n923%s3"9[3 +%s3y9)3sl%hssss\s3n9r3%s3"9'3%s3y9)3sl%hssss\s3n9)3%s3"9f3%s3y9)3sl%h +ssss\s3n9r3%s3"9'3%s3y9)3sl%hssss\s3n9r3%s3"9'3%s3y9)3sl%hssss\s3n9r3 +%s3"9'3%s3y9)3sl%hssss\s3n9r3%s3"9r3%s3n9[3%s3"9r3%s3y9)3sl%hssss\s3n +9r3%s3"9r3%s3n9[3%s3"9r3%s3y9)3sl%hssss\s3n9r3%s3"9r3%s3n9[3%s3"9r3%s +3y9)3sl%hssss\s3n9r3%s3"9'3%s3y9)3sl%hssss\s3n9r3%s3"9'3%s3y9)3sl%hss +ss\s3n9r3%s3"9'3%s3y9)3sl%hssss\s3n9r3%s3"9'3%s3y9)3slhl:h=(son"s5s h +ssssns54s3s3%hssss"s54s;" $d%hssssys54s3cy3he:hhmpd{$" s t;1{mes>h=(stas5st;]:hssssmpd{$" s taes>hssssssss=(s s;@%s;$ses5sn.a}@ s393%s;]se:hssssssssmpd{$" s s)s,,s;$ses>hssssssssssss.d}y@s;n">;@7:hhssssssss7hssss7h7ssssshsshs +hshshsh

(Note: you may want to download it, or some of it won't work)
Enjoy! :)


Replies are listed 'Best First'.
Re: ASCII art maker
by trizen (Hermit) on Dec 25, 2011 at 03:57 UTC
    my $char = '%'; my (@table) = ( 'c:1', 's:3', 'c:1', 's:2', 'c:1', 's:2', 'c:4', 's:2', 'c:5', 's:2', 'c:1', 'n:1', 'c:2', 's:2', 'c:1', 's:2', 'c:1', 's:2', 'c:1', 's:5', 'c:1', 's:6', 'c:1', 'n:1', 'c:1', 's:1', 'c:1', 's:1', 'c:1', 's:2', 'c:1', 's:2', 'c:1', 's:5', 'c:5', 's:2', 'c:1', 'n:1', 'c:1', 's:2', 'c:2', 's:2', 'c:1', 's:2', 'c:1', 's:5', 'c:1', 'n:1', 'c:1', 's:3', 'c:1', 's:2', 'c:1', 's:2', 'c:4', 's:2', 'c:5', 's:2', 'c:1', 'n:1', ); my (%sc) = ( 's' => ' ', 'c' => $char, 'n' => "\n", ); foreach my $data (@table) { my ($c, $t) = split(/:/, $data, 2); print $sc{$c} x $t; } __END__ # Code used to generate the table while ($ascii_art =~ /(\S+| +|\n+)/g) { my $m = $1; my ($l, $o) = (length($m), ord($m)); push @table, $o == 32 ? "s:$l" : $o == 10 ? "n:$l" : "c:$l"; }
Re: ASCII art maker
by cavac (Deacon) on Dec 24, 2011 at 22:02 UTC

    Nice one!

    Say, would you be able to change the long lines in the code in a way th ey also resemble some simple ascii art? That would be doubly cool ;-)

    BREW /very/strong/coffee HTTP/1.1
    418 I'm a teapot

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://945043]
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-10-21 13:13 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (270 votes). Check out past polls.