my %env_to_httpheader = ( 'HTTP_USER_AGENT' => 'User-Agent', 'HTTP_HOST' => 'Host', 'HTTP_TE' => 'Accept-Encoding', 'CONTENT_LENGTH' => 'Content-Length', # from here on blurry from memory: (and probably more to include as well..) 'CONTENT_ENCODING' => 'Content-Encoding', 'CONTENT_TYPE' => 'Content-Type', ); my $headers; foreach my $key (keys %env_to_httpheader) { if (exists $ENV{$key}) { # $headers->{ $env_to_httpheader{$key} } = $ENV{$key}; # "The optional $header argument should be a reference to an HTTP::Headers object or a plain array reference of key/value pairs." push(@{ $headers }, $env_to_httpheader{$key}); push(@{ $headers }, $ENV{$key}); } }