in reply to Re: Re: backticks in CGI
in thread trouble populating array with input from a file
#!/usr/local/bin/perl use Date::Calc qw(Delta_DHMS); @receivers = qw(70CM 50CM H-OH MULTIBEAM GALILEO MULTIBAND METHANOL K-BAND); $dbfile = 'rxdb.dat'; #Get last modify time of DB file rxdb.dat $mtime = (stat("$dbfile"))[9]; ($fsec,$fmin,$fhour,$fmday,$fmonth,$fyear) = localtime($mtime); #Get current time ($nsec,$nmin,$nhour,$nmday,$nmonth,$nyear) = (localtime(time))[0..5]; #Get current time ($nsec,$nmin,$nhour,$nmday,$nmonth,$nyear) = (localtime(time))[0..5]; #Open DB and see if receivers are present and available foreach $package (@receivers) { open(DB, "$dbfile") or die "Can't open $dbfile!: $!"; $i = 0; while ($line = <DB>) { if ($line =~ m/package(\s+)= $package/i) { last } $i++; } close(DB); #$i lists the 'package =' line of the receiver we #want. To determine if it is present and available, #we require 'yes' to be found on lines $i+18 and #$i+19 @db = `more $dbfile`; if ($db[$i+18] =~ m/yes/ && $db[$i+19] =~ m/yes/) { #Selected receiver is present & available. #Calculate difference between file date and current date. ($days, $hours) = Delta_DHMS( $fyear+1900, $fmonth+1, $fmday, $fhour, $fmin, $fsec, $nyear+1900, $nmonth+1, $nmday, $nhour, $nmin, $nsec); $total = sprintf "%3.0f", ($days*24)+$hours; } else { $total = 0; } print "$package $total\n"; }
|
|---|