Created
July 19, 2012 09:09
-
-
Save josejuan/3142332 to your computer and use it in GitHub Desktop.
anonymous grid computing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use bigint; | |
print "Cache-Control: no-cache\n"; | |
print "Content-type: text/html\n"; | |
print "\n"; | |
my $data = '/ruta/del/archivo/de/datos/agc.dat'; | |
# se espera como parámetros algo como | |
# 12345,678 | |
# donde el primer valor es T y el segundo H | |
if($ENV{'QUERY_STRING'} =~ /^([0-9]+),([0-9]+)$/) { | |
my ($t, $h) = ($1, $2); | |
if(!open(F, "< $data")) { | |
print "read state fail"; | |
} else { | |
$_ = readline(F); chomp; | |
if(/^([0-9]+),([0-9]+)$/) { $t += $1; $h += $2; } | |
close(F); | |
print (($h * 40000000000000000000000000000000000000000) / $t) . "\n"; | |
if(!open(F, "> $data")) { | |
print "write state fail"; | |
} else { | |
print F "$t,$h"; | |
close(F); | |
} | |
} | |
} else { | |
print "syntax error"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment