NAME

U - Utilities

SYNOPSIS

use U;

U::ewarn 'Subject', 'Body text';

U::email 'user@example.com', 'Hello', "Body\n";

my $rounded =  U::round 5.6777, 2;  # "5.68"

DESCRIPTION

U contains utility functions used across the project. These functions should not depend on other dynamic things.

FUNCTIONS

ewarn

U::ewarn $subject, $body, $attachments;

Log the first two arguments using "warn" in L and send an email to the debug address configured in C::config->{Debug}{to}.

Configuration example:

Debug => {
	to      =>  'recepient@example.com',
	subject =>  'Invoice: Exception',
},

See C::load for details.

email

U::email $to, $subject, $body;
U::email $to, $subject, $body, \@attachments;
U::email \%opts;

Send an email using Email::Stuffer.

Configuration is read from C::config->{email} and is expected to contain transport settings (server, port, ssl, username, password, from, and so on).

Attachments can be provided as an array reference. Each element is passed to Email::Stuffer->attach (scalar or arrayref of arguments).

Configuration example:

	email => {
		stop_subj =>  '[Debug]',
		# stop_mail =>  'recepient@example.com',

		from      =>  'source@example.com',
		transport =>  '::SMTP::Persistent',

		server    =>  'email-smtp.eu-west-1.amazonaws.com',
		port      =>  '587',
		ssl       =>  'starttls',
		username  =>  'AKIA...',
		password  =>  'XYZ',
  },

See C::load for details.

round

my $str =  U::round $number;
my $str =  U::round $number, $places;

Round a number to $places decimals (default: 2) using "bfround" in Math::BigFloat. Returns a formatted string.

SEE ALSO

C, L, Email::Stuffer.