Scratching an itch - interpolable HTTP Status constants

When working on larger web applications, I prefer to use HTTP::Status to provide human-readable constant names in the code. This is especially helpful for anything other than the common 200, 404 or 500 status codes.

But the constants exported by HTTP::Status are basically subs:

if ($response->code == HTTP_OK) { ... }

this is fine for most cases, but not when you want interpolable variables, for example, in hash keys.

So I wrote HTTP::Status::Constants. It's a simple wrapper around HTTP::Status that provides read-only scalar constants for the HTTP_* constants.

3 Comments

What is the problem with hash keys?

my %hash = (
HTTP_OK() => 'OK',
);

Leave a comment

About Robert Rothenberg

user-pic I was born on the Moon but kidnapped by astronauts and raised in the suburbs of Grumman. Eventually, I drifted along the Gulf Stream to Northern Europe. Blogs about Perl, Puppet, Linux, programming, and whatever etc.