syntax error at validate.pl line 29, near "() "
syntax error at validate.pl line 35, near "}"
Execution of validate.pl aborted due to compilation errors.
####
#!/usr/local/bin/perl -w
use strict;
use warnings; # Already on with -w, but doesn't hurt to be explicit
#
# Version 0.1
#
##
##
Variable "$log_file" is not imported at validate.pl line 25.
Variable "$spec_file" is not imported at validate.pl line 26.
Variable "$data_in_file" is not imported at validate.pl line 27.
Variable "$data_out_file" is not imported at validate.pl line 28.
Variable "$spec_file" is not imported at validate.pl line 29.
Variable "$data_in_file" is not imported at validate.pl line 29.
Variable "$data_out_file" is not imported at validate.pl line 30.
Variable "$log_file" is not imported at validate.pl line 30.
Global symbol "$spec_file" requires explicit package name at validate.pl line 24.
Global symbol "$data_in_file" requires explicit package name at validate.pl line 24.
Global symbol "$data_out_file" requires explicit package name at validate.pl line 24.
Global symbol "$log_file" requires explicit package name at validate.pl line 24.
Global symbol "$max_errors" requires explicit package name at validate.pl line 24.
Global symbol "$log_file" requires explicit package name at validate.pl line 25.
Global symbol "$log_file" requires explicit package name at validate.pl line 25.
Global symbol "$spec_file" requires explicit package name at validate.pl line 26.
Global symbol "$spec_file" requires explicit package name at validate.pl line 26.
Global symbol "$data_in_file" requires explicit package name at validate.pl line 27.
Global symbol "$data_in_file" requires explicit package name at validate.pl line 27.
Global symbol "$data_out_file" requires explicit package name at validate.pl line 28.
Global symbol "$data_out_file" requires explicit package name at validate.pl line 28.
Global symbol "$spec_file" requires explicit package name at validate.pl line 29.
Global symbol "$data_in_file" requires explicit package name at validate.pl line 29.
Global symbol "$data_out_file" requires explicit package name at validate.pl line 30.
Global symbol "$log_file" requires explicit package name at validate.pl line 30.
Global symbol "$max_errors" requires explicit package name at validate.pl line 30.
Global symbol "$spec_line" requires explicit package name at validate.pl line 32.
syntax error at validate.pl line 32, near "() "
validate.pl has too many errors.
##
##
my ($spec_file, $data_in_file, $data_out_file, $log_file, $max_errors) = @ARGV;
##
##
# Note that you don't have to put quotes "..." around $spec_file
open ($spec_file, $spec_file) or die "Can not open file $spec_file, $!";
##
##
open ($log_file, ">", $log_file) or die "Can not open file $log_file, $!";
##
##
my $syntax = "
syntax: $0
The purpose of this program is ...
";
(my $spec_file = shift) or die $syntax;
(my $data_in_file = shift) or die $syntax;
(my $data_out_file = shift) or die $syntax;
# etc...
##
##
$i++; # Increment $i (duh!)
##
##
foreach my $attribute (@data_in_attributes) {
if ($attribute =~ m/$spec_all_attributes[$attribute_position][1]/) { # validate data attribute type by performing
# lookup for the regular expression from the spec memory structure
push (@data_out_attributes, $attribute); # Correct data type, the output value is same as input value
} else {
push (@data_out_attributes, $spec_all_attributes[$attribute_position][2]);
# Bad data type, use default provided in the spec for output value
$total_errors++;
print log_file "Error ", $total_errors, ". Data type error on line: ", $line_number,
", attribute: ", $attribute_position + 1, " (", $spec_all_attributes[$attribute_position][0], ")\n";
}
last DATALINE if ($total_errors >= $max_errors); # terminate if too many errors
$attribute_position++;
}
##
##
foreach my $attribute (@data_in_attributes) {
# validate data attribute type by performing
# lookup for the regular expression from the spec memory structure
if ($attribute =~ m/$spec_all_attributes[$attribute_position][1]/) {
# Correct data type, the output value is same as input value
push @data_out_attributes, $attribute;
} else {
# Bad data type, use default provided in the spec for output value
push @data_out_attributes, $spec_all_attributes[$attribute_position][2];
$total_errors++;
print log_file "Error ", $total_errors,
". Data type error on line: ", $line_number,
", attribute: ", $attribute_position + 1,
" (", $spec_all_attributes[$attribute_position][0], ")\n";
}
# terminate if too many errors (<-- but perhaps this is obvious??)
last DATALINE if ($total_errors >= $max_errors);
$attribute_position++;
}