I'm not sure if im going anywhere with the coding I have so far with this time stamp issue. I'm tryint to create a whos online script that shows all the members online and when they logout it removes them from the list or if they end up being idle for 30 mins it removes them from the list.
If theres a much better way to do this please tell me, and if the following code is good and would work please help me with the problem I have.
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time
++$addsecs);
@months = ("1","2","3","4","5","6","7","8","9","10","11","12");
@days = ("Sun","Mon","Tue","Wed","Thur","Fri","Sat");
if ($sec < 10) {$sec = "0$sec";}
if ($min < 10) {$min = "0$min";}
if ($hour < 10) {$hour = "$hour";}
if ($hour > 11) {$ap = "PM";}
if ($hour < 12) {$ap = "AM";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour eq 00) { $hour = "12"; }
if ($hour > 12) {
$hour = ($hour - 12);
$ap = "p.m.";
}
$millyear = $year + 1900;
$date = "@days[$wday]:$mday:@months[$mon]:$millyear";
$time = "$hour:$min:$sec:$ap:$date";
use DB_File; # optional; overrides default
tie %who, "DB_File", "$path/whosonline" or die "Can't open FILENAME: $
+!\n"; # open database tie hash to db
$who{$Account::account} = "$time"; #account-value time-key
@person = keys(%who);
foreach $timer (values %who) {
($hr, $mins, $secs, $appm, $day, $daynumber, $month, $year) = split(/:
+/, $timer);
print <<EOF;
$hr, $mins, $secs, $appm, $day, $daynumber, $month, $year
EOF
if ($hour eq $hr) {
if (@days[$wday] eq $day) {
$member = $who;
print <<EOF;
$member
EOF
The code is not fully finished because im stuck.
Now I want to check the DBM file for all the time that members logged in. I use a foreach statement to check all the times in the DBM file and if the time is idle then it removes that key/value, and if it is not idle then it adds the new key/value to it, meaning it refreshes the members time. The thing is when it does come to a point where the time is idle, I don't know how to delete that certain time and its key because I don't know the key.
Thank you,
Anthony
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.