December 2009 Archives

Getting started with Params::Validate

So I have a module that exports some functions that each take a single hashref as an argument, and I want to be sure that:

  1. I really have got a single hashref
  2. The contents of the hashref conform to my specification

I'd never used Params::Validate before now, so this looked like an ideal opportunity.

Here's what I came up with:

sub _validate_me {

# Raise exception if we don't have exactly one hashref
validate_po…

About Stephen Cardie

user-pic I blog about Perl.