areyouready344
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_da ta,$open_c olor_blue, $bold_open ,$1,$bold_ close,$clo se_color_b lue,$close _column_da ta,$open_c olumn_data ,$3,$open_ color_blue ,$4,$close _color_blu e,$5,$clos e_column_d ata,$close _row,"\n";
# print $blank_row;
}
}
print "</body>";
print "</html>";
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></
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\.)(\
{
print $start_row,$open_column_da
# print $blank_row;
}
}
print "</body>";
print "</html>";
How does the @random_color relate $open_color_blue and $close_color_blue?
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...
<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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Super thanks Wilcoxon for staying up late for this working solution.
Thanks again,
Thanks again,
ASKER
solution works