[svn r8003] fix fucking qm script AGAIN

This commit is contained in:
expo
2008-08-06 13:20:35 +02:00
parent dde18d6740
commit c0ccf197ab

View File

@@ -92,7 +92,8 @@ while (<CSV>) {
if (!$ref) { $ref = ""; } if (!$ref) { $ref = ""; }
if (!$grade) { $grade = ""; } if (!$grade) { $grade = ""; }
if (!$desc) { $desc = ""; } if (!$desc) { $desc = ""; }
# hacked in by DL, as was acting weirdly due to uninitialized variables if (!$area) { $area = ""; }
print "number $number, grade $grade, area $area, desc $desc, ref $ref, station $station, completion $completion\n";
if (($completion ne "") and ($ref ne "")) if (($completion ne "") and ($ref ne ""))
{ {
@@ -177,25 +178,13 @@ print "\nInformation: Done\n";
# Parse the CSV file # Parse the CSV file
sub parse_csv { sub parse_csv {
my $line = $_[0]; my @fields=split /\t/;
my @parsedline = (); my @unquoted=();
my $field = ''; foreach $_ (@fields) {
$_ =~ s/\"//g;
while ($line =~ m{ \G(?:^|,) push (@unquoted, $_);
(?: "((?> [^"]*) (?> "" [^"]*)*)" | ([^",]*)) }gx) {
if ($2) {
$field = $2;
} elsif ($1) {
$field = $1;
$field =~ s/""/"/g;
} else {
$field = '';
}
push(@parsedline, $field);
} }
return @unquoted;
return(@parsedline);
} }
# Usage # Usage