IO::Util 1.5 review

Download
by rbytes.net on

License: Perl Artistic License
File size: 13K
Developer: Domizio Demichelis
0 stars award from rbytes.net

IO::Util is a selection of general-utility IO function.

SYNOPSIS

use IO::Util qw(capture slurp Tid Lid Uid load_mml);
capture()
# captures the selected filehandle
$output_ref = capture { any_printing_code() } ;
# now $$output_ref eq 'something'

# captures FILEHANDLE
$output_ref = capture { any_special_printing_code() } *FILEHEANDLER ;

# append the output to $captured
capture { any_printing_code() } *FILEHEANDLER , $captured
# now $captured eq 'something'

# use another class to tie the handler
use IO::Scalar ;
$IO::Util::TIE_HANDLE_CLASS = 'IO::Scalar'
slurp()
$_ = '/path/to/file' ;
$content_ref = slurp ;
$content_ref = slurp '/path/to/file' ;
$content_ref = slurp *FILEHANDLE ;

# append the file content to $content
$_ = '/path/to/file' ;
slurp $content;
slurp '/path/to/file', $content ;
slurp *FILEHANDLE, $content ;
Tid(), Lid(), Uid()
$temporarily_unique_id = Tid ; # 'Q9MU1N_NVRM'
$locally_unique_id = Lid ; # '2MS_Q9MU1N_P5F6'
$universally_unique_id = Uid ; # 'MGJFSBTK_2MS_Q9MU1N_PWES'
A MML file (Minimal Markup Language)
< opt >
< !-- a multi line
comment-- >
< parA >
< optA >01< /optA >
< optA >02< /optA >
< optA >03< /optA >
< /parA >
< parB >
< optA >04< /optA >
< optA >05< /optA >
< optA >06< /optA >
< optB >
< key >any key< /key >
< /optB >
< /parB >
< /opt >
load_mml()
$struct = load_mml 'path/to/mml_file' ;
$struct = load_mml $mml_string ;
$struct = load_mml *MMLFILE ;
$struct = load_mml ..., %options ;

# $struct = {
# 'parA' => {
# 'optA' => [
# '01',
# '02',
# '03'
# ]
# },
# 'parB' => {
# 'optA' => [
# '04',
# '05',
# '06'
# ],
# 'optB' => {
# 'key' => 'any key'
# }
# }
# }

Requirements:
Time::HiRes
Sys::Hostname
Perl

IO::Util 1.5 search tags