# Poor Man's CGI Module for Perl
#
-# (c) 2002--2010 Martin Mares <mj@ucw.cz>
+# (c) 2002--2011 Martin Mares <mj@ucw.cz>
# Slightly modified by Tomas Valla <tom@ucw.cz>
#
# This software may be freely distributed and used according to the terms
sub http_get($) {
my $h = shift @_;
$h =~ tr/a-z-/A-Z_/;
- return $ENV{"HTTP_$h"} || $ENV{"$h"};
+ return $ENV{"HTTP_$h"} // $ENV{"$h"};
}
### Parsing of Arguments ###
exit;
}
} else {
- http_error "405 Method Not Allowed", "Allow: GET, HEAD, PUT";
+ http_error "405 Method Not Allowed", "Allow: GET, HEAD, POST";
}
}
for my $a (values %$args) {
my $r = ref($a->{'var'});
- defined($a->{'default'}) or $a->{'default'}="";
+ $a->{'default'} //= '';
if ($r eq 'SCALAR') {
${$a->{'var'}} = $a->{'default'};
} elsif ($r eq 'ARRAY') {
# BUG: IE 3.01 on Macintosh forgets to add the "--" at the start of the boundary string
# as the MIME specs preach. Workaround borrowed from CGI.pm in Perl distribution.
- my $agent = http_get("User-Agent") || "";
+ my $agent = http_get("User-Agent") // "";
$boundary = "--$boundary" unless $agent =~ /MSIE\s+3\.0[12];\s*Mac/;
$boundary = "\r\n$boundary";
$boundary_len = length($boundary) + 2;