ycgtech
asked on
Perl print if
Disclaimer: I am new to Perl
Here is my code snippet:
print if ($a > $b);
print "\n";
I have this code in a while loop going through a txt file. The end result is that if ($a > $b) is false, then the code will still print the blank line. I would like to incorporate "\n" in the print if, but I cannot figure out how. I have searched for hours, I am sure I am missing something simple.
Thanks,
Here is my code snippet:
print if ($a > $b);
print "\n";
I have this code in a while loop going through a txt file. The end result is that if ($a > $b) is false, then the code will still print the blank line. I would like to incorporate "\n" in the print if, but I cannot figure out how. I have searched for hours, I am sure I am missing something simple.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or, if you want to keep it two print statements:
if($a > $b) {
print;
print "\n";
}
if($a > $b) {
print;
print "\n";
}
ASKER