Minor changes to perl scripts.

This commit is contained in:
LevelX2 2014-01-19 09:52:21 +01:00
parent 3167fc0896
commit 87b4f03dfb
2 changed files with 8 additions and 4 deletions

View file

@ -3,7 +3,7 @@
#author: North #author: North
use strict; use strict;
use Scalar::Util qw(looks_like_number);
my $dataFile = "mtg-cards-data.txt"; my $dataFile = "mtg-cards-data.txt";
my $setsFile = "mtg-sets-data.txt"; my $setsFile = "mtg-sets-data.txt";
@ -48,6 +48,8 @@ close(DATA);
sub cardSort { sub cardSort {
if (!looks_like_number(@{$a}[2])) { return -1; }
if (!looks_like_number(@{$b}[2])) { return 1; }
if (@{$a}[2] < @{$b}[2]) { return -1; } if (@{$a}[2] < @{$b}[2]) { return -1; }
elsif (@{$a}[2] == @{$b}[2]) { return 0;} elsif (@{$a}[2] == @{$b}[2]) { return 0;}
elsif (@{$a}[2] > @{$b}[2]) { return 1; } elsif (@{$a}[2] > @{$b}[2]) { return 1; }

View file

@ -3,7 +3,7 @@
#author: North #author: North
use strict; use strict;
use Scalar::Util qw(looks_like_number);
my $dataFile = "mtg-cards-data.txt"; my $dataFile = "mtg-cards-data.txt";
my $setsFile = "mtg-sets-data.txt"; my $setsFile = "mtg-sets-data.txt";
@ -48,6 +48,8 @@ close(DATA);
sub cardSort { sub cardSort {
if (!looks_like_number(@{$a}[2])) { return -1; }
if (!looks_like_number(@{$b}[2])) { return 1; }
if (@{$a}[2] < @{$b}[2]) { return -1; } if (@{$a}[2] < @{$b}[2]) { return -1; }
elsif (@{$a}[2] == @{$b}[2]) { return 0;} elsif (@{$a}[2] == @{$b}[2]) { return 0;}
elsif (@{$a}[2] > @{$b}[2]) { return 1; } elsif (@{$a}[2] > @{$b}[2]) { return 1; }
@ -71,7 +73,7 @@ foreach my $card (sort cardSort @setCards) {
$toPrint .= "@{$card}[2]|@{$card}[0]"; $toPrint .= "@{$card}[2]|@{$card}[0]";
} }
} }
open CARD, "> " . lc($sets{$setName}) . ".txt"; open CARD, "> " . lc($sets{$setName}) ."_unimplemented.txt";
print CARD $toPrint; print CARD $toPrint;
close CARD; close CARD;