in reply to If statement issue from a Noob

haukex++'s solution is good, and asks an important question, since your specs were not internally consistent regarding exactly 55. However, in case you were curious about your logic specifically:

Your version doesn't compile for me as-is: you have an unmatched curly bracket. Clean up the formatting to only do one thing per line, and you should see it:

if ($tempdesc >= 55) { if ($tempdesc2 =~ /electric/) { print FH_OUTFILE "\n"; } else { print FH_OUTFILE "free_batteries\n"; } } else { print FH_OUTFILE "\n"; } }

After removing that final } (shown in the SSCCE below): it seems to me to do what you want (assuming that "greater than 55" means "greater than or equal to 55", to match your >=).

use warnings; + # ALWAYS!!! use strict; + # ALWAYS!!! open FH_OUTFILE, '>&', \*STDOUT or die "err dup STDOUT = $!"; + # added for SSCCE foreach my $hashref( + # added for SSCCE {price => 55, title => 'i am expensive electric, and want a blank' + }, # added for SSCCE {price => 55, title => 'i am expensive gasoline, and want to print + something else'}, # added for SSCCE {price => 54, title => 'i am cheap electric, and want a blank' }, + # added for SSCCE {price => 54, title => 'i am cheap gasoline, and want a blank' }, + # added for SSCCE ) { + # added for SSCCE my $tempdesc = $hashref->{price}; my $tempdesc2 = $hashref->{title}; print FH_OUTFILE "-"x40, " START\n", "TITLE = '$tempdesc2' \@ PRIC +E = '$tempdesc'\n"; # added for SSCCE if ($tempdesc >= 55) { if ($tempdesc2 =~ /electric/) { print FH_OUTFILE "\n"; } else { print FH_OUTFILE "free_batteries\n"; } } else { print FH_OUTFILE "\n"; } print FH_OUTFILE '.'x40, " END\n"; + # added for SSCCE } + # added for SSCCE __END__ ---------------------------------------- START TITLE = 'i am expensive electric, and want a blank' @ PRICE = '55' ........................................ END ---------------------------------------- START TITLE = 'i am expensive gasoline, and want to print something else' @ +PRICE = '55' free_batteries ........................................ END ---------------------------------------- START TITLE = 'i am cheap electric, and want a blank' @ PRICE = '54' ........................................ END ---------------------------------------- START TITLE = 'i am cheap gasoline, and want a blank' @ PRICE = '54' ........................................ END

If our outputs are not your desired output, you'll need to clarify.