PerlIsGood
Programmer
Below I've posted code block from a script I whipped up to show the number of messageboard users currently online. I just can't seem to get my head wrapped around why this isn't working the way I want
This is really driving me nuts cause the code doesn't cause any errors, it just always produces 0, no matter who's logged in or not. So I guess I can assume it's not finding a match in the nested foreach, or its just skipping that altogether... :/
I've tested @online and @members individually to make sure they're at least holding values. Any help...?
Code:
open FILE, "./directory/memberlist.txt" or die "Couldn't open file: $!";
@members = <FILE>;
close FILE;
$whoson = 0;
#@online contains info from log.txt file (who's on now)
#log.txt tracks all hits, so check against memberlist
#and increment $whoson if match found
foreach ( @online ) {
( $user, $time ) = split ( /\|/, $_ );
foreach ( @members ) {
if ( $_ eq $user ) { $whoson++; }
}
}
print qq~<b><u>Members Online:</u></b> $whoson</font>\n~;
This is really driving me nuts cause the code doesn't cause any errors, it just always produces 0, no matter who's logged in or not. So I guess I can assume it's not finding a match in the nested foreach, or its just skipping that altogether... :/
I've tested @online and @members individually to make sure they're at least holding values. Any help...?