A couple more pointers for you:
First, use POSIX::strftime to format your time stamp:If you still insist that the month is all lower case, then you could always use lc.use POSIX; my $date_for_logfile = strftime( "%e %B %C%y, %T", localtime);
$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:
Unless i need a very specific format for my time stamp, that is exactly what i use. POSIX::strftime() takes care of the rest. ;)my $ts = scalar localtime;
Now, check_ip will look like:my $ip = '127.0.0.1'; print ip_error() unless check_ip($ENV{REMOTE_ADDR},$ip);
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 check_ip { my ($ip1,$ip2) = @_; return $ip1 eq $ip2; }
Of course, now check_ip seems a bit overkill, so maybe we could instead use: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'), ; }
I think there is nothing wrong with hacking out some code, but before i share it with others, i refactor out the nonesense.print ip_error() unless $ENV{REMOTE_ADDR} eq $ip;
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)
In reply to (jeffa) Re: Quick 'n very dirty flash-variables updatescript
by jeffa
in thread Quick 'n very dirty flash-variables updatescript
by teabag
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |