#Lets write some stuff print "Content-type: text/html; charset=utf-8\n\n";
print << "EOF1";
Miracles
EOF1
if($form{'miracle'}){ ($r, $poss) = believe_in_miracle($form{'miracle'}); if($r == 1){ print " Такое точно бывает, причем с вероятностью $poss %:)";} else {print " Нет, сынок, это фантастика =)";} }
Comments 31
(The comment has been removed)
спасибо))
Reply
Reply
Reply
Reply
Reply
Reply
Reply
#!/usr/bin/perl
sub believe_in_miracle {
my $miracle = shift @_;
my $length = $miracle =~ tr///c;
$length = 0 if not $length;
my $poss = 100 - ($length/1000);
$poss=sprintf "%0.2f", $poss;
return (0,undef) if $length >= 1000; # = e4
return (1,$poss);
}
# Lets read some miracles
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$form{$name} = $value;
}
#Lets write some stuff
print "Content-type: text/html; charset=utf-8\n\n";
print << "EOF1";
Miracles
EOF1
if($form{'miracle'}){
($r, $poss) = believe_in_miracle($form{'miracle'});
if($r == 1){ print "
Такое точно бывает, причем с вероятностью $poss %:)";}
else {print "
Нет, сынок, это фантастика =)";}
}
print << "EOF3";
EOF3
... )
Reply
Leave a comment