in reply to Quick 'n very dirty flash-variables updatescript

A couple more pointers for you:

First, use POSIX::strftime to format your time stamp:
use POSIX; my $date_for_logfile = strftime( "%e %B %C%y, %T", localtime);
If you still insist that the month is all lower case, then you could always use lc.

$date_for_logfile is rediculously long, how about just $log_date instead? or $ts for timestamp? By the way, did you know that you can get a very nice generic timestamp by simply using:

my $ts = scalar localtime;
Unless i need a very specific format for my time stamp, that is exactly what i use. POSIX::strftime() takes care of the rest. ;)


Second item is your check_ip sub. One important lesson i have learned over the years is that unless the sub contains the word print, it should not print. Also, don't use global variables like that, not when you can pass them in:
my $ip = '127.0.0.1'; print ip_error() unless check_ip($ENV{REMOTE_ADDR},$ip);
Now, check_ip will look like:
sub check_ip { my ($ip1,$ip2) = @_; return $ip1 eq $ip2; }
and our new sub, ip_error() will return (not print) the HTML to be used for our error. I will use CGI.pm to output the HTML, you should too:
sub ip_error { return header, start_html( -title => 'Error', -style => { -code => q|body { font-family: "Verdana, Arial"; text-alig +n: center; color: red }|, }, ), b('Invalid ip-number'), ; }
Of course, now check_ip seems a bit overkill, so maybe we could instead use:
print ip_error() unless $ENV{REMOTE_ADDR} eq $ip;
I think there is nothing wrong with hacking out some code, but before i share it with others, i refactor out the nonesense.

Hope this helps, on the whole your script is nice, but you really should have cleaned it up a bit before you posted. As well as using strict and warnings, good indentation is a must, and until you develop your own style of 'proper' indentation, run your code through perltidy first. Here is a clue that you are not indenting properly: when you see two ending braces lined up with each other on two or more consecutive lines:

} }
Happy coding to you! ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)