Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

comment on

( #3333=superdoc: 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');

In reply to mtg2xsv-obfuscated by premchai21

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2023-06-01 21:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found