collection of python libs developed for testing purposes

calc.cgi 464B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use CGI;
  5. my $q = CGI -> new();
  6. $q->import_names;
  7. my $op = $Q::op;
  8. my $a = $Q::a;
  9. my $b = $Q::b;
  10. my $ops = {
  11. add => sub { $_[0] + $_[1] },
  12. sub => sub { $_[0] - $_[1] },
  13. mul => sub { $_[0] * $_[1] },
  14. div => sub { $_[0] / $_[1] },
  15. };
  16. if (defined $ops->{$op}) {
  17. print "Content-type: text/plain\n\n";
  18. print $ops->{$op}->($a, $b);
  19. print "\n";
  20. } else {
  21. warn "unsupported operator: $op\n";
  22. }