in $ENV{REMOTE_USER} =~ m/(m[1|3][[:alpha:]]{3}\d{2})/i do you really mean to match an 'm' followed by one of '1', '|' or '3', or should it be m/(m[13]...?
Generally use statements should go at the top of the file - that is effectively their scope in any case and it makes them easier to find. Strictures should always be on and at the very top of the file of course.
for (my $i = 0; $i <= 3; $i++) {
is more Perlish as:
for my $i (0..3) {
for ($x = 0; $x < 3; $x++) { $rand = rand(255); $hex[$x] = sprintf ("%x", $rand); if ($rand < 9) { $hex[$x] = "0" . $hex[$x]; } if ($rand > 9 && $rand < 16) { $hex[$x] = "0" . $hex[$x]; } } $colors[$i] = "\#" . $hex[0] . $hex[1] . $hex[2]; }
can be replaced by:
$hex[$_] = sprintf "%02x", rand(255) for 0..2;
In fact the whole colour generation loop could be replaced by:
$color[$_] = sprintf "#%02x%02x%02x", rand 255, rand 255, rand 255 for + 0..4;
In general the code would be easier to read with fewer comments. At least use a little vertical white space to make it easier to find sections of code. It's not so bad if you are using a syntax highlighting editor, but otherwise some of the code is simply impossible to see.
In reply to Re^2: A CGI whiteboard in Perl
by GrandFather
in thread A CGI whiteboard in Perl
by OfficeLinebacker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |