Parse tests, handling spaces.

This commit is contained in:
Colin Kuskie 2009-10-10 16:27:33 -07:00
parent 0273e2da57
commit 23b1cb47c5
2 changed files with 38 additions and 4 deletions

View file

@ -261,7 +261,11 @@ shipment, a colon, and the cost of insuring a shipment of that value.
sub _parseInsuranceRates {
my $rates = shift;
my @lines = split /\r?\n/, $rates;
$rates =~ tr/\r//d;
my $number = qr/\d+(?:\.\d+)?/;
my $rate = qr{ \s* $number \s* : \s* $number \s* }x;
return () if ($rates !~ m{ \A (?: $rate \r?\n )* $rate (?:\r\n)? \Z }x);
my @lines = split /\n/, $rates;
my @table = ();
foreach my $line (@lines) {
$line =~ s/\s+//g;