Hi: I am fairly new to PERL so I apologize for the simplicity of my issue. I'm trying to create an If/Else statement that will look at the contents of two variables from a data extraction ($hashref.) I need to print a blank in a file if the price field is less than 55. I also need the output to be blank if the price field is greater than 55 but the title field contains the word "electric." If the item is greater than 55 without the word electric in the title, I need the phrase "free_batteries" to be output. I've almost got it working. If the item is less than 55, it works, but if the item is greater than 55 with the word "electric" in the field, it's adding "free_batteries" to the record. I'm lost as to what I'm doing wrong. I'm sure this is a simple fix for someone who knows PERL. Any help you can lend is greatly appreciated. - Tom
$tempdesc = $hashref->{price}; $tempdesc2 = $hashref->{title}; if ($tempdesc >= 55) { if ($tempdesc2 =~ /electric/) {print FH_OUTFILE "\n";} else {print FH_OUTFILE "free_batteries\n";}} else {print FH_OUTFILE "\n";} }
In reply to If statement issue from a Noob by tomdee27
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |