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

It's not a template. I'm just using the PERL print command to spit out the HTML code. The code will executing on the server, which I believe is default for CGI.
  • Comment on Re^2: Conditional statement in HTML code.

Replies are listed 'Best First'.
Re^3: Conditional statement in HTML code.
by Eily (Monsignor) on Feb 06, 2018 at 18:39 UTC

    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'>";

      Thanks. This is a while loop, so my mistake was not assigning the $color value inside the loop. It's working now.