Journal Angron's Journal: chk_org.pl
#!/usr/bin/perl
sub sort_color($$);
%colors = ( 'White' => 1,
'Blue' => 2,
'Black' => 3,
'Red' => 4,
'Green' => 5,
'Artifact' => 6,
'Land' => 7
);
@array = populate_array($ARGV[0]);
@array = sort { sort_color($a, $b) } @array;
for (@array) {
print_card($_);
}
exit;
sub sort_color($$) {
($card1, $card2) = @_;
$color1 = $colors{${$card1}[0]};
$color2 = $colors{${$card2}[0]};
return ($color1 $color2);
#return -1 if $color1 > $color2;
#return 0 if $color1 == $color2;
#return 1 if $color1 ;
for $i (0
$line = $lines[$i];
if( $line =~ m/^-/ ) { next; }
chomp($line);
if( $line !~ m/\(\w+ \w+\)\s*$/ ) { next; }
# should only have info line of any given card.
#$line =~ s/^\s*(.*?)\s*$/\1/g; #strip whitespace
substr($line, 4, 1, "|");
substr($line, 24, 1, "|");
$line =~ s/\s{4,}(\d+\/\d+)? \((\w+) (\w+)\)\s*/|\1|\2|\3/;
@parts = split(/\|/,$line);
for(@parts) {
s/^\s*(.*?)\s*$/\1/g;
}
#print join("|", @parts), "\n";
($cc, $name, $type, $pt, $color, $rarity) = @parts;
$text = "";
while($lines[$i+1] !~ m/^-/) {
$i = $i + 1;
$text
}
chomp($text);
#print "$name: $text\n";
push(@array, [$color, $name, $cc, $type, $text, $pt, $rarity]);
}
return @array;
}