Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

mtg2xsv-obfuscated

by premchai21 (Curate)
on Nov 15, 2002 at 06:01 UTC ( #213081=obfuscated: print w/replies, xml ) Need Help??

Certainly nowhere near the best around, but a converter I obfuscated after writing for a friend.
#!/usr/bin/perl use strict;no strict 'refs';use Getopt::Long;use subs qw/nil/; use vars qw/$__ @cards %opts %fields @fields $count %fieldXform/;$|++; srand 500;$__=rand;$__.=rand;$__=~s/0\.//g;%fieldXform = eval do{undef$/; <DATA>};*{$_="nil"}=sub{ %opts = (quiet => 0);GetOptions(\%opts,'quiet!'); $count=0;*nil=sub{};$/='';};eval; while (<>) { my %card; eval((qw[nil last next last])[(/^Copyright/?1:0)+(/^Card/?0:2)]); pos=(s/^(Card \#)([^:])/$1:$2/mg*0); while (m[\G^([A-Z][A-Za-z\ \#&/]+):[\ \t]+(.*?)\n (?=$|[A-Z][A-Za-z\ \#&/]+:)]xgsm) { my ($k,$v) = ($1,$2);{my $k =~ tr/A-Z/a-z/;#; $k =~ s/Card/num/g; $v =~ tr/a-z/a-z/c; ;$k =~ s/\#/num/g; $k =~ tr/A-Za-z/_/c; $k =~ s/_+/_/g;$k =~ s/^\s*//; $k =~ s/\s*$//; } $k = (exists $fieldXform{$k} ? $fieldXform{$k} : $k); $v =~ s/^\s*//; $v =~ s/\s*$//; $v =~ s/\s+/ /g; (($k eq 'Pow/Tou')?{my ($tou,$pow) = split /\//,$v; if ($v =~ m!^n/a$!i) {my$i=0;$_.=($i++?substr($v,1,2):substr($v,0,2)) for ($tou,$po +w);} @card{reverse qw{Tou Pow}} = reverse($pow,$tou); $fields{$_}=$k for(reverse qw(Tou Pow)); }:{$card{$fields{$_[0]}=$_[0]}=pop@_; })->($k,$v); } %card or next; push @cards,\%card; $count++; ($count%10) || (print STDERR "\r$count") unless $opts{quiet}; } @fields = keys %fields; ($\,$/)=split//,' |'; print join '|',map{index($_,'|')<0 or die$_;$_} @fields;{; } for my $card (@cards) { print join '|',map{defined($_) ? do{index($_,'|')<0 or die$_;$_} : + ''} @{$card}{@fields}; }print STDERR "" unless $opts{quiet};exit unless $opts{quiet}; __DATA__ ('Pow/Tgh' => 'Pow/Tou', 'Pow/Tough' => 'Pow/Tou', 'Pwr/Tgh' => 'Pow/Tou', 'Card Title' => 'Card Name', 'Color' => 'Card Color', 'Type' => 'Card Type', 'Cost' => 'Mana Cost', 'Casting Cost' => 'Mana Cost', 'Artrist' => 'Artist', 'Artists' => 'Artist', 'CardCard Type' => 'Card Type');

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2016-10-01 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (7 votes). Check out past polls.