#!/usr/bin/perl
($gid,$gdata) = split (/&/,<STDIN>);
($n,$v) = split (/=/,$gid);
($n,$data) = split (/=/,$gdata);
print"Content-type:text/html\n\n";
$filename = 'data.txt';
open(myfile,"$filename");
@getrec = <myfile>;
close(myfile);
$cntrec = @getrec;
unlink("$filename");
open(myfile,">$filename");
for $i (0 .. $cntrec-1) {
$id = $i + 1;
if ($v ne $id) {
print myfile $getrec[$i];
} else {
($oid,$odata) = split (/,/,$getrec[$i]);
print myfile "$oid,$data,\n";
$found=1;
}
}
close(myfile);
if ($found){print'Update ok';}else{print'Not found';}
จำนวน : 24 บรรทัด