Perl::Metrics::Metric - A Perl Document Metric


This class provides objects that represent a single metric on a single document (although that document might actual exist as a number of duplicate files in the index).


In addition to the general methods provided by Class::DBI, this class has the following additional methods.


In the Perl::Metrics system all documents are identified by the hexidecimal MD5 value for their newline-localized contents.

The hex_id accessor returns this id for the document that the metric is for.


The package returns a string which contains the class name of the metrics package that generated the metric.


The name accessor returns the name of the metric.

This name is package-specific. That is, a metric with a package of 'Foo' and name 'some_metric' is different to a metric with package 'Bar' and the same name 'some_metric'.

The metric name itself must be a valid Perl identifier. This test is done using the _IDENTIFIER function from Params::Util.


In Perl::Metrics some metrics packages will produce metrics that are "version-unstable". In other words, if the metrics package is upgraded, the metrics need to be recalculated.

The version accessor returns the version of the metrics package at the time the metric was calculated.


The value accessor returns the value of the accessor. This could be a number, word, or anything else. Please note that a value of undef, does not mean the lack of a metric, but rather it means "unknown" or "indeterminate" or has some other signficant meaning (in the context of the metrics package).

files @conditions

Because metrics are stored based on a document identifier rather than by file name, if there are duplicate files indexed, one set of metrics may related to more than one file.

The files accessor searchs for all indexed ::File objects that have a matching hex_id to the ::Metric object.


Bugs should be reported via the CPAN bug tracker at

For other issues, contact the author.


Adam Kennedy <>


Perl::Metrics, PPI


Copyright 2005 - 2008 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.