Changeset 27751 for trunk/pstamp/scripts/pstamp_request_file
- Timestamp:
- Apr 23, 2010, 11:33:14 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_request_file (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_request_file
r26289 r27751 187 187 for (my $i = 0; $i < scalar @colNames; $i++) { 188 188 my $writeType = $colWriteType[$i]; 189 $outFits->write_col( $writeType, $i + 1, 1, 1, $numRows, $colData->[$i], $status ); 189 my $data = $colData->[$i]; 190 if ($writeType == TULONG) { 191 die "invalid integer data found in column $i\n" unless validIntegers($data); 192 } elsif ($writeType == TDOUBLE) { 193 die "invalid numeric data found in column $i\n" unless validNumbers($data); 194 } 195 $outFits->write_col( $writeType, $i + 1, 1, 1, $numRows, $data, $status ); 190 196 check_fitsio( $status ); 191 197 } … … 312 318 } 313 319 320 sub checkValid { 321 my $aref = shift; 322 my $float = shift; 323 324 return 0 if !defined $aref; 325 326 my $valid = 0; 327 my $row = 0; 328 foreach my $val (@$aref) { 329 $row++; 330 if ($float) { 331 if (!($val =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)) { 332 $valid = 0; 333 print STDERR "Error on row $row: '$val' is not a valid number\n"; 334 last; 335 } 336 } else { 337 if ($val =~ /\D/) { 338 $valid = 0; 339 print STDERR "Error on row $row: '$val' is not a valid integer\n"; 340 last; 341 } 342 } 343 $valid = 1; 344 } 345 346 return $valid; 347 } 348 sub validIntegers { 349 return checkValid(@_, 0); 350 } 351 352 sub validNumbers 353 { 354 return checkValid(@_, 1); 355 } 356 357 314 358 sub printhelp 315 359 {
Note:
See TracChangeset
for help on using the changeset viewer.
