Link to home
Start Free TrialLog in
Avatar of ycgtech
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,
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ycgtech
ycgtech

ASKER

Thank you very much!
Or, if you want to keep it two print statements:

if($a > $b) {
    print;
    print "\n";
}