NAME

Egg::Plugin::Tools - Convenient method collection for Egg.

SYNOPSIS

use Egg qw/ Tools /;

$e->escape_html($html);

$e->unescape_html($plain);

$e->sha1_hex('abcdefg');

$e->comma('12345.123');

my @array= (1..100);
$e->shuffle_array(\@array);

DESCRIPTION

It is a plugin that collects convenient methods.

METHODS

encode_entities ([HTML_STR], [ARG])

encode_entities of HTML::Entities is done.

my $plain = $e->encode_entities($html);
  • Alias = escape_html, eHTML

encode_entities_numeric ([HTML_STR], [ARG])

encode_entities_numeric of HTML::Entities is done.

decode_entities ([HTML_STR], [ARG])

decode_entities of HTML::Entities is done.

my $html = $e->decode_entities($plain);
  • Alias = unescape_html, ueHTML

uri_escape ([URI_STR])

uri_escape of URI::Escape is done.

my $escape= $e->uri_escape($uri);
  • Alias = escape_uri, eURI

uri_escape_utf8 ([URI_STR])

uri_escape_utf8 of URI::Escape is done.

uri_unescape ([URI_STR])

uri_unescape of URI::Escape is done.

  • Alias = unescape_uri, ueURI

sha1_hex ([TEXT])

sha1_hex of Digest::SHA1 is done.

my $hex= $e->sha1_hex($text);

md5_hex ([TEXT])

md5_hex of Digest::MD5 is done.

my $hex= $e->md5_hex($text);

create_id ([LENGTH], [METHOD])

A unique HEX value to use it as general ID is returned.

LENGTH is length of the returned HEX value. It disappears when it is too short in unique. Default is 32.

METHOD is a method for the generation of the HEX value. Sha1 or md5 can be specified. Default is sha1.

my $id= $e->create_id;

comma ([NUMBER])

The comma is put in NUMBER in each treble.

my $price= $e->comma($number);

shuffle_array ([ARRAY])

The result of mixing ARRAY is returned.

my $shuffle= $e->shuffle_array($array);

filefind ([REGEXP], [PATH_LIST])

The result of File::Find is returned.

The regular expression of the retrieved file is passed to REGEXP.

The retrieved passing is passed to PATH_LIST.

When anything doesn't become a hit to the retrieval, undefined is returned.

if (my $files= $e->filefind(qr{\.pm$}, '/path/to/find')) {
   ............
   .....
}

referer_check ([BOOL])

If environment variable 'HTTP_REFERER' is the one of the site, true is returned.

If REQUEST_METHOD is POST and doesn't exist, it becomes false if BOOL is given.

True is returned when there is no value in HTTP_REFERER.

$e->request->host_name is used for the site judgment.

if ($e->referer_check(1)) {
    ..............
    ......
}

gettimeofday

Gettimeofday of Time::HiRes is returned.

my $elabor = $e->gettimeofday;

mkpath ([PATH_LIST])

mkpath of File::Path is done.

$e->mkpath(qw{ /path/to/create });

rmtree ([PATH_LIST])

rmtree of File::Path is done.

$e->rmtree(qw{ /path/to/create });

jfold ([STRING])

jfold of Jcode is done.

The return value is ARRAY reference.

my $cutstr= $e->jfold($string);

timelocal ([DATE_STRING or TIME_ARRAY])

Time::Local is done.

If it is DATE_STRING, the character string of the form such as '2008/01/01 01:01:01' and '2008-01-01 01:01:01' can be passed.

When TIME_ARRAY is passed, ARRAY with the value that starts from the age is passed. Please note reversing completely with the argument passed to Time::Local.

my $time_var= $e->timelocal('2008/01/01 01:01:01');
  or
my $time_var= $e->timelocal(qw/ 2008 01 01 01 01 01 /);

SEE ALSO

Egg::Release, URI::Escape, HTML::Entities, Digest::SHA1, Digest::MD5, File::Find, Time::HiRes, File::Path, Jcode, Time::Local,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.