POD AN::Tools

From Alteeve Wiki
Jump to navigation Jump to search

 AN!Tools :: AN::Tools :: POD AN::Tools




Serves only to load all other AN::Tools::* modules in a common object and provide shortcuts to their methods.


  use AN::Tools;
  # Get a common object handle on all AN::Tools::* modules.
  my $an=AN::Tools->new();
  # Again, but this time tell the AN::Tools::String module to force the use of
  # UTF-8 mode when reading it's built-in XML words file.
  my $an=AN::Tools->new({
        String  =>      {
                force_utf8      =>      1,


This module provides access to all the AN::Tools::* modules' methods. For details on what methods each module provides, please see their respective perldocs or visit the AN::Tools webite, https://alteeve.ca.

Some modules can be passed load-time values to alter how the AN::Tools suite starts. Where this is the case, you can pass a hash reference where the key structure is '$hashref->{module_name}{method_name}=arg' or, when a method takes several parameters, '$hashref->{module_name}{method_name}{arg_name}=arg'.

Currently supported load-time arguments:

To tell AN::Tools to force the use of UTF-8 mode when reading it's internal XML words file. The format is: {String}{force_utf8}=[0|1].


All AN::Tools::* modules expects the data they receive to be in UTF-8 encoded format. Likewise, they return UTF-8 encoded strings. If you are getting weird output or are seeing a "wide character in print" error, check that you are not getting double-encoded UTF-8 strings by casting your data as UTF-8 in the first place.


Below are the detailed usage instructions for the methods provided by this module.



  use AN::Tools;
  # Get a handle on the MB::Tools object.
  my $an=AN::Tools->new;
  # With the handle to this module's object, you access the rest of the
  # AN::Tools::* suite of modules by calling them by their method name. For
  # example, to access AN::Tools::Math's 'round' method, call it like this:
  $an->Math->round({number=>30.33754, places=>2});
  # The format is always:


This is the constructor method used to access this object's handle on the various AN::Tools::* objects. It also provides access to the methods provided by these modules as seen in the example above. Access to each module's methods is formatted this way to make the resulting code clearer and somewhat self-documenting. This access method cannot be (safely) circumvented as AN::Tools does not use @ISA to access the child (sibling) module's methods nor do the other methods Export their methods. Attempting to directly access the child modules will fail as they require access to one another and expect to be able to do this via the AN::Tools module.

The current supported modules are:

  • AN::Tools::Alert
  • AN::Tools::Math
  • AN::Tools::Readable



  # See if an error state exists.
  die "AN::Tools failed on the last call. Error was: ".$an->error if $an->error;


This method takes no arguments. It simply returns the last error if set, otherwise it returns undef. This method only has use if '$an->Alert->no_fatal_errors' has been set to '1'. Otherwise the method call with an error would have died before returning.

Child Module Access

In traditional perl parlance, these modules are siblings of this module. However, it makes a bit more sense to think of them as child objects because of how access is structured.



  # Access the example 'foo' method.


The AN::Tools::Alert module handles warnings and errors.

Please read this modules POD documentation using your favourite POD reader. The most common one at the command shell being perldoc.

perldoc AN::Tools::Alert



  # Access the example 'foo' method.


The AN::Tools::Math method handles mathmatical operations.

Please read this modules POD documentation using your favourite POD reader. The most common one at the command shell being perldoc.

perldoc AN::Tools::Math



  # Access the example 'foo' method.


The AN::Tools::Readable method handles converting large bits of data, generally numbers, sizes and UNIX timestamps, between more human readable formats and back

Please read this modules POD documentation using your favourite POD reader. The most common one at the command shell being perldoc.

perldoc AN::Tools::Readable



  # Get a handle on AN::Tool's internal data store.
  my $data=$an->data;


All AN::Tools modules store their data in a common, user-accessible hash reference. This allows easy access to variables read in from configuration files, a given language's word strings and so forth.

For example, say that your configuration file had the variable-value pair:

foo::bar = baz

You could see the value read for foo::bar by:

print "The value of 'foo::bar' is: [$data->{foo}{bar}]\n"; # prints "The value of 'foo::bar' is: [baz]";

Another example, though not realistic, would be to access the word string 'an_0000' in the language 'en_CA':

my $word=$an->data()->{words}{lang}{en_CA}{key}{an_0000}{content}; print "Word: [$word].\n"; # prints "Word: [AN::Tools rapid development suite.]."

Realistically though, you'll probably want to access strings via 'AN::Tools::String's 'get_word()' method.


Other modules in the AN::Tools suite:



Copyright (c) 2009 Alteeve's Niche!. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.