Iterator::File::Utility - IF utility functions


Iterator-File documentation Contained in the Iterator-File distribution.

Index


Code Index:

NAME

Top

Iterator::File::Utility - IF utility functions

DESCRIPTION

Top

Private mixin utility class for Iterator::File.

Not intended to be used directly or externally.

new(%config)

The constructor can take a hash as an argument. If the hash contains keys debug or verbose, with either set to true, those types of messages will be enabled. Note that enabling debug automatically enables verbose.

To avoid temporary code changes, debug can be also be enabled by setting the environmental variable ITERATOR_FILE_DEBUG to a true value.

_verbose(@text)

Prints @text if verbose or debug is enabled.

_debug(@text)

Prints @text if debug is enabled.

SEE ALSO

Top

Iterator::File

AUTHOR

Top

William Reardon, <wdr1@pobox.com>

COPYRIGHT AND LICENSE

Top


Iterator-File documentation Contained in the Iterator-File distribution.
package Iterator::File::Utility;

## $Id: Utility.pm,v 1.4 2008/06/11 05:20:07 wdr1 Exp $

use 5.006;
use strict;
use warnings;

our $VERSION = substr(q$Revision: 1.4 $, 10);

our %default_config =
  (
   'verbose' => 0,
   'debug'   => 0,
  );

sub new {
  my ($class, %config) = @_;

  %config = (%config, %default_config);
  if ($ENV{'ITERATOR_FILE_DEBUG'}) {
    $config{'debug'} = $ENV{'ITERATOR_FILE_DEBUG'};
  }

  my $self =  bless(\%config, $class);
  

  return $self;
}


sub _verbose {
  my $self = shift;

  return unless ($self->{verbose} || $self->{debug});
  print @_, "\n";
}


sub _debug {
  my $self = shift;

  return unless ($self->{debug});
  print @_, "\n";
}


1;
__END__
# Below is stub documentation for your module. You'd better edit it!