xcolors.cgi
来自「嵌入式WEB」· CGI 代码 · 共 38 行
CGI
38 行
#!/usr/bin/perl -wTuse strict;use HTML::Template;my $rgb_file = "/usr/X11/lib/X11/rgb.txt";my $template = "/usr/local/apache/templates/xcolors.tmpl";my @colors = parse_colors( $rgb_file );print "Content-type: text/html\n\n";my $tmpl = new HTML::Template( filename => $template );$tmpl->param( colors => \@colors );print $tmpl->output;sub parse_colors { my $path = shift; local *RGB_FILE; open RGB_FILE, $path or die "Cannot open $path: $!"; while (<RGB_FILE>) { next if /^!/; chomp; my( $r, $g, $b, $name ) = split; # Convert to hexadecimal #RRGGBB format my $rgb = sprintf "#%0.2x%0.2x%0.2x", $r, $g, $b; my %color = ( rgb => $rgb, name => $name ); push @colors, \%color; } close RGB_FILE; return @colors;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?