How would you go about converting this to Perl? I'm trying on my own, but I keep running into some problems (like the @users=<FILE>; part)?
Any help would be apreciated.
#!/usr/bin/perl
$refresh=3600; #log time
$log="file.dat";
print "Content-type: text/html\n\n";
$ip=$ENV{'REMOTE_ADDR'};
$time=time;
$script=$ENV{'SCRIPT_NAME'};
open(FILE,$log);
flock (FILE,3);
@users=<FILE>;
close(FILE);
foreach $lines (@users) {
chop($lines);
($ips,$times)=split('=',$lines);
$timeoff=$time-$times;
if($ips ne $ip){
if($timeoff>0 && $timeoff<$refresh) {
push @new,$lines;
}
}
}
$line="$ip=$time";
push @new,$line;
$online=$#new;
$online++;
open (WRITE,">$log");
flock (WRITE,3);
foreach $lines (@new) {
print WRITE "$lines\n";
}
close(WRITE);
exit;