dkhalfe has asked for the wisdom of the Perl Monks concerning the following question:
Hello all, I am stumped and need some assistance. My code:
#variables my $x=0; my @keys; my @holder; my @array_hash; my $blank = "-"; my $numerical_value = "num"; my $string_value = "string"; my $filter = "filter"; my $append = "append"; for(my $c = 0; $c <= $num_elements; $c++) { if('$hash{$filter[$c]->[4]}' eq '$filter') { if (exists($hash{$filter[$c]->[0]})) { print "VALUE EXISTS", "\n"; # continue; if('$hash{$filter[$c]->[3]}' eq '$numerical_value') { #process filtering for numerical value if ((eval "$hash{$filter[$c]->[0]} $filter[$c]->[1 +] $filter[$c]->[2]")) { print OUTFILE $line, "\n"; } } if('$hash{$filter[$c]->[3]}' eq '$string_value') { #process filtering for string value if ((eval "'$hash{$filter[$c]->[0]}' $filter[$c]-> +[1] '$filter[$c]->[2]'")) { print OUTFILE $line, "\n"; } } } else { print "COLUMN NAME DOES NOT EXIST. CHECK FILTER FILE F +OR ANY POSSIBLE ERRORS AND RE-RUN PROGRAM. PROGRAM WILL NOW TERMINATE +.", "\n"; exit 0; } }
I am using a for loop to iterate through the entirety of the array I create when reading in from an input file. As long as $c is less than or eq to the number of elements in the array -- if the hash of the column name is equal to "filter", continue -- if the hash of the column name exists, continue (else display error and terminate program) -- if the hash of the column name equals 'num' or 'string' (respectively), continue -- if the hash of the column name evaluates as true, print to OUTPUT file.
However, no output is printed to my OUTFILE (note: this is only part of my code, the other part of code relates to storing the information from a filter file and input file. It has been tested and works so I know the problem lays in the above mentioned code. Please help!! Thank you!
Here is the input file so you can make sense of what is stored in the array and what is going on in the eval statement
column relationship value num_or_string filter_or_append order a <= 0.3 num filter 1 b = abc string append 3 c <= 0.3 num filter 2
Note if ((eval "'$hash{$filter[$c]->[0]}' $filter[$c]->[1] '$filter[$c]->[2]'")) translates to -- if column a <= 0.3 -- print OUTFILE line.
|
|---|