Skip to content

Instantly share code, notes, and snippets.

@backroot
Last active May 9, 2024 21:49
Show Gist options
  • Save backroot/8d8bd272a161bec38c4bf6f4eca9594c to your computer and use it in GitHub Desktop.
Save backroot/8d8bd272a161bec38c4bf6f4eca9594c to your computer and use it in GitHub Desktop.
Get HTTP Headers by perl
#!/usr/bin/perl --
use strict;
use warnings;
use CGI;
my $q = CGI->new;
my %headers = map { $_ => $q->http($_) } $q->http();
print $q->header('text/plain');
print "------------------------------\n";
print "Got the following headers:\n";
print "------------------------------\n";
for my $header ( keys %headers ) {
print "$header: $headers{$header}\n";
}
print "\n";
print "------------------------------\n";
print "Server Env:\n";
print "------------------------------\n";
for my $key ( sort ( keys ( %ENV ) ) ) {
print "$key: $ENV{$key}\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment