Link to home
Start Free TrialLog in
Avatar of areyouready344
areyouready344Flag for United States of America

asked on

Add a predefined set of colors to the if statement in this Perl code

I need to add a predefined set of colors for a html "font color tag" with the variable name of $open_color with each color looping through the if statement.

Here's the predefined set of colors,

my @random_color= qw(990099 00CC00 CC0066 000033 993300 0000ff 006666);

Here's the full code....

#!/usr/bin/perl

use strict;
use warnings;

open FH, '<', 'a_all.txt' or die $!;

$/='__Data__';

# Html table variables

my $open_table ="<table border=\"1\">";
my $close_table ="</table>";
my $start_row ="<tr>";
my $close_row ="</tr>";
my $open_column_header ="<th>";
my $close_column_header ="</th>";
my $open_column_data ="<td>";
my $close_column_data ="</td>";
my $open_color_blue ="<font color=\"#0000ff\">";
my $close_color_blue ="</font>";
my $blank_row ="<tr><tb></tb><tb></tb></tr>";
my $bold_open ="<b>";
my $bold_close ="</b>";
my @random_color= qw(990099 00CC00 CC0066 000033 993300 0000ff 006666);

# This script creates a html table


print "<html>";
print "<body>";
print $open_table;






   while(<FH>)
       {
            if(/^\@([^\n]*).*((^1\.)(\s*[^\n:]*)([^\n]*))/ms)
            {


           print $start_row,$open_column_data,$open_color_blue,$bold_open,$1,$bold_close,$close_color_blue,$close_column_data,$open_column_data,$3,$open_color_blue,$4,$close_color_blue,$5,$close_column_data,$close_row,"\n";
             #   print $blank_row;
              }


   }

print "</body>";
print "</html>";
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

How does the @random_color relate $open_color_blue and $close_color_blue?
Avatar of areyouready344

ASKER

those are the html font color tags


<font color=\"#0000ff\"> $1 <\font>

$open_color_blue = <font color=\"#0000ff\">
$close_color_blue = <\font>


I want the #0000ff value to change using the color values in the @random_color array variable though each while loop cycle.
I should just drop off the blue variable name and just called it

$open_color_tag
$close_color_tag

thanks for the question...

ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
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
Super thanks Wilcoxon for staying up late for this working solution.

Thanks again,
solution works