in reply to Re^2: Conditional statement in HTML code.
in thread Conditional statement in HTML code.

The code to build the page is on the server side by default (and in pretty much all sane cases I guess?) yes, but you can have some code to change the page dynamically when displaying it.

If that's just a string, you can use interpolation. You should first put the value in a variable and then interpolate, not only is this clearer, but it's also easier to do:

my $bgcolor = ($ref->{'status'} == 'open') ? 'blue' : 'red'; print "<td bgcolor='$bgcolor'>";

Replies are listed 'Best First'.
Re^4: Conditional statement in HTML code.
by techjohnny (Novice) on Feb 06, 2018 at 18:51 UTC
    Thanks. This is a while loop, so my mistake was not assigning the $color value inside the loop. It's working now.
        This is working below: if ($ref->{'status'} =~ /Open/i) { $color = 'green' ; } else { $color = 'red' ; } ;