- NAME
- SYNOPSIS
- DESCRIPTION
- BUGS
- SEE ALSO

# NAME

ActiveState::Handy - Collection of small utility functions

# SYNOPSIS

     use ActiveState::Handy qw(add);
     my $sum = add(1, 2, 3);

# DESCRIPTION

This module provides a collection of small utility functions.

The following functions are provided:

add( @numbers )

  Adds the given arguments together.

cat( $filename )

  Returns the content of a file. Same as file_content( $filename ). This function is still present for legacy reasons.

cat_text( $filename )

  Just like cat() but will read the file in text mode. Makes a difference on some platforms (like Windows).

ceil( $number )

  Rounds the number up to the nearest integer. Same as POSIX::ceil().

cp_files( $from, $to, @files )

  Copies files from source to destination directory. Destination directory will be created if it doesn't exist. Function dies if any file cannot be found.

cp_tree( $from, $to )

  Recursively copies all files and subdirectories from source to destination directory. All destination directories will be created if they don't already exist.

file_content( $filename )
file_content( $filename, $content )

  Get or set the content of a file. The file I/O takes place in binary mode.

  If called with a single argument, then try to read the given file and return `undef` if the file could not be opened.

  If called with two arguments, try to write the given $content to the file denoted by the given $filename, creating the file itself or missing directories as needed. If the file can't be opened or created this function will croak. There is no return value when the file is set.

iso_date( $time )
iso_date( $y, $m, $d )

  Returns a ISO 8601 formatted date; YYYY-MM-DD format. See `http://www.cl.cam.ac.uk/~mgk25/iso-time.html`.

iso_datetime( $time )
iso_datetime( $y, $m, $d, $h, $m, $s )

  Returns a ISO 8601 formatted timestamp; YYYY-MM-DDThh:mm:ss format. See `http://www.cl.cam.ac.uk/~mgk25/iso-time.html`.

xml_esc( $text )

  Will escape a piece of text so it can be embedded as text in an XML element.

xml_clean( $text )

  Will remove control characters so it can be embedded as text in an XML element. Does not perform escaping.

stringf( $format, %hash )

  printf-style template expansion compatible with the String::Format module.

For legacy reasons this module re-exports the functions run(), shell_quote() and decode_status() from `ActiveState::Run`.

# BUGS

none.

# SEE ALSO

ActiveState::Run