---
name: "HTML::Mason::Tools"
section: "3pm"
platform: "linux"
package: "libhtml-mason-perl"
version: "1:1.60-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/HTML::Mason::Tools"
---

# HTML::Mason::Tools(3pm)

Function library used internally in Mason

## NAME

HTML::Mason::Tools - Function library used internally in Mason

## DESCRIPTION

This module contains exportable functions that are intended to be used by other Mason modules.

The documentation here is primarily intended to be used by Mason core developers.

Others who choose to use these functions do so at their own risk, as they may change from release to release.  You have been warned.

## FUNCTIONS

- read\_file

  This function takes a file name and an optional argument indicating whether or not to open the final in binary mode.  It will return the entire contents of the file as a scalar.

- paths\_eq

  Given to paths, this function indicates whether they represent the same location on the filesystem.  It does not account for symlinks.

- compress\_path

  This turns a component path into a filesystem-friendly path by escaping potentially meaningful characters.

- absolute\_comp\_path

  Given a component path and a directory path, this function returns the absolute component path, prepending the directory path if needed.

- mason\_canonpath

  This function cleans up a component path and returns its canonical version.  It is largely the same as File::Spec::Unix::canonpath, with a few additional cleanups.

- pkg\_installed

  Given a module name, this function returns true or false to indicate whether or not a corresponding *.pm* file exists.

- pkg\_loaded

  Given a module name, this function returns true or false to indicate whether or not the module has been loaded into memory.

- load\_pkg

  Given a module name, this function attempts to load it.  It takes an additional boolean parameter indicating whether or not to throw an exception if the module cannot be found.  By default, if the module cannot be found, this function simply returns false.

  All errors generate exceptions no matter what.

  If the module is loaded successfully, this function returns true.

- taint\_is\_on

  Returns a boolean value indicating whether taint mode is on or not.

- coerce\_to\_array

  Given a scalar, which may be a reference, this function attempts to return an array.  It throws an HTML::Mason::Exception::Params exception if this can't be done.

  This function is called from the generated component code as part of a component's argument handling.

- coerce\_to\_hash

  Given a scalar, which may be a reference, this function attempts to return a hash.  It throws an HTML::Mason::Exception::Params exception if this can't be done.

  This function is called from the generated component code as part of a component's argument handling.

- checksum

  Computes a simple checksum of a string. Used for Compiler::object\_id.
