#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; my %colorchart; while( my ($color_code, $element_id) = split(/\s+/, )) { $colorchart{$element_id} = $color_code; } my $style; foreach my $key (sort keys %colorchart) { $style .= "#b$key {background-color: $colorchart{$key}}\n"; } print header, start_html(-title=>'Colors', -style => {-code => $style}); foreach my $key (sort keys %colorchart) { print qq^
$key - $colorchart{$key}
\n^; } print end_html; __DATA__ #0000FF 1 Blue #8A2BE2 2 BlueViolet #A52A2A 3 Brown #DEB887 4 BurlyWood #5F9EA0 5 CadetBlue #7FFF00 6 Chartreuse