Data::Hub::Util -
Nothing exported by default
RE_ABSTRACT_KEY, RE_ABSTRACT_ADDR, $VALUE_ALL, $VALUE_ALL_REC, $PATTERN_QUERY, $PATTERN_QUERY_SUBKEY, $PATTERN_QUERY_VALUE, $PATTERN_QUERY_RANGE, $PATTERN_QUERY_KEY, %TYPEOF_ALIASES, FS, is_abstract_key, is_abstract_addr, curry, typeof, addr_shift, addr_pop, addr_normalize, addr_parent, addr_name, addr_basename, addr_split, addr_join, addr_ext, addr_base, path_shift, path_pop, path_push, path_normalize, path_parent, path_name, path_split, path_join, path_ext, path_is_absolute, path_basename, fs_handle, file_read, file_read_binary, file_read_crown, file_create, file_write, file_write_binary, file_copy, file_move, file_remove, dir_read, dir_create, dir_copy, dir_copy_contents, dir_is_system, dir_move, dir_remove, dir_remove_contents
RE_ABSTRACT_KEY, RE_ABSTRACT_ADDR, $VALUE_ALL, $VALUE_ALL_REC, $PATTERN_QUERY, $PATTERN_QUERY_SUBKEY, $PATTERN_QUERY_VALUE, $PATTERN_QUERY_RANGE, $PATTERN_QUERY_KEY, %TYPEOF_ALIASES, FS, is_abstract_key, is_abstract_addr, curry, typeof, addr_shift, addr_pop, addr_normalize, addr_parent, addr_name, addr_basename, addr_split, addr_join, addr_ext, addr_base, path_shift, path_pop, path_push, path_normalize, path_parent, path_name, path_split, path_join, path_ext, path_is_absolute, path_basename, fs_handle, file_read, file_read_binary, file_read_crown, file_create, file_write, file_write_binary, file_copy, file_move, file_remove, dir_read, dir_create, dir_copy, dir_copy_contents, dir_is_system, dir_move, dir_remove, dir_remove_contents
This module requires these other modules and libraries:
Encode
File::Copy
Fcntl
Error::Programatic
Error::Simple
Data::Hub::Address
Perl::Module
Parse::StringTokenizer
IO::Dir
IO::File
Exporter
This example will not abort:
# Load this module
use Data::Hub::Util qw(:all);
TODO The regex RE_ABSTRACT_KEY uses an error-prone search for | and * (these are allowed in hashfile key names.
This example:
curry({a=>{b=>'c'}})->get('/a/b');
will return:
c
This example:
typeof('foo.bar', {});
will return:
data-hash
This example:
typeof('/with/path/foo.bar', []);
will return:
data-array
This example:
typeof('foo.bar', 'baz');
will return:
data-scalar-bar
This example:
my $addr = '/one/two/{/i/am/three}/four';
join(':', addr_shift($addr), addr_shift($addr), addr_shift($addr),
addr_shift($addr));
will return:
one:two:{/i/am/three}:four
This example:
my $addr = '/one/two';
my $last = addr_pop($addr);
"$last,$addr"
will return:
two,/one
See also "_normalize"
This example:
addr_normalize('/');
will return:
/
This example:
addr_normalize('/a/');
will return:
/a
This example:
addr_normalize('/a/b/..');
will return:
/a
This example:
addr_normalize('/a/../b');
will return:
/b
This example:
addr_normalize('/a/../../b');
will return:
/b
This example:
addr_normalize('/a/.../b');
will return:
/a
This example:
addr_normalize('/a/.../');
will return:
/a
This example:
addr_normalize('/a/...');
will return:
/a
This example:
addr_normalize('/a/.../..');
will return:
/a
This example:
addr_normalize('/a/../...');
will return:
/
This example will not return a defined value:
addr_parent();
This example will not return a defined value:
addr_parent('');
This example:
addr_parent('/');
will return:
/
This example:
addr_parent('/a');
will return:
/
This example:
addr_parent('/a/b/..');
will return:
/
This example:
addr_parent('a/b/');
will return:
a
This example:
addr_parent('a/b.c');
will return:
a
This example will not return a defined value:
addr_name('');
This example:
addr_name('/');
will return:
This example:
addr_name('/a');
will return:
a
This example:
addr_name('/a/b/..');
will return:
a
This example:
addr_name('a/b/');
will return:
b
This example:
addr_name('a/b.c');
will return:
b.c
This example:
scalar(addr_split(''));
will return:
0
This example:
join ' ', addr_split('/');
will return:
This example:
join ' ', addr_split('/a');
will return:
a
This example:
join ' ', addr_split('/a/b/..');
will return:
a
This example:
join ' ', addr_split('a/b/');
will return:
a b
This example:
join ' ', addr_split('a/b.c');
will return:
a b.c
See also "_normalize"
This example:
addr_join('/');
will return:
/
This example:
addr_join('/a', '/');
will return:
/a
This example:
addr_join('/a/', 'b/..');
will return:
/a
This example:
addr_join('/a/..', '/b');
will return:
/b
This example:
addr_join('/a/../', '../b');
will return:
/b
This example:
addr_join('/a/.../', 'b');
will return:
/a
This example:
addr_join('/a/', '.../');
will return:
/a
This example:
addr_join('/a/', '...');
will return:
/a
This example:
addr_join('/a/', 'b/');
will return:
/a/b
This example:
addr_join('/a/', 'b');
will return:
/a/b
This example:
addr_join('/a', '/b');
will return:
/a/b
This example:
addr_join('/a', 'b');
will return:
/a/b
This example:
addr_join('/a', 'b', 'c');
will return:
/a/b/c
This example will not return a defined value:
addr_ext(undef);
This example:
addr_ext('foo.txt');
will return:
txt
This example:
addr_ext('/foo.txt');
will return:
txt
This example:
addr_ext('./foo.txt');
will return:
txt
This example:
addr_ext('../foo.txt');
will return:
txt
This example:
addr_ext('/foo/foo.txt');
will return:
txt
This example:
addr_ext('/foo.bar.txt');
will return:
txt
This example:
addr_ext('/foo/bar.');
will return:
This example will not return a defined value:
addr_ext('/foo/bar');
This example will not return a defined value:
addr_ext('.metadata');
This example:
addr_ext('.metadata.bak');
will return:
bak
This example will not return a defined value:
addr_basename(undef);
This example will not return a defined value:
addr_basename('/');
This example:
addr_basename('foo.txt');
will return:
foo
This example:
addr_basename('foo.txt/');
will return:
foo
This example:
addr_basename('/foo.txt');
will return:
foo
This example:
addr_basename('./foo.txt');
will return:
foo
This example:
addr_basename('../foo.txt');
will return:
foo
This example:
addr_basename('/foo/foo.txt');
will return:
foo
This example:
addr_basename('/foo.bar.txt');
will return:
foo.bar
This example:
addr_basename('/foo/bar.');
will return:
bar
This example:
addr_basename('/foo/bar');
will return:
bar
This example will not return a defined value:
addr_basename('.metadata');
This example:
addr_basename('.metadata.bak');
will return:
.metadata
This example:
addr_base('/a/b/{d}');
will return:
/a/b
This example:
addr_base('/a/b/d');
will return:
/a/b/d
This example:
my $path = '/one/two/../four';
join(':', path_shift($path), path_shift($path), path_shift($path),
path_shift($path));
will return:
one:two:..:four
This example:
my $path = '/one/two';
my $last = path_pop($path);
"$last,$path"
will return:
two,/one
This example:
my $path = '/one/two';
my $count = path_push($path, 'three');
"$path"
will return:
/one/two/three
This example:
path_split('');
will return:
0
This example:
join ' ', path_split('/');
will return:
This example:
join ' ', path_split('/a');
will return:
a
This example:
join ' ', path_split('/a/b/..');
will return:
a
This example:
join ' ', path_split('a/b/');
will return:
a b
This example:
join ' ', path_split('a/b.c');
will return:
a b.c
This example will not return a defined value:
path_basename(undef);
This example:
path_basename('foo.txt');
will return:
foo
This example:
path_basename('/foo.txt');
will return:
foo
This example:
path_basename('./foo.txt');
will return:
foo
This example:
path_basename('../foo.txt');
will return:
foo
This example:
path_basename('/foo/foo.txt');
will return:
foo
This example:
path_basename('/foo.bar.txt');
will return:
foo.bar
This example:
path_basename('/foo/bar.');
will return:
bar
This example:
path_basename('/foo/bar');
will return:
bar
This example:
path_basename('.bashrc');
will return:
.bashrc
This example:
path_basename('.bashrc.tmp');
will return:
.bashrc
This example:
path_basename('/no-dots');
will return:
no-dots
This example will not return a defined value:
path_ext(undef);
This example:
path_ext('foo.txt');
will return:
txt
This example:
path_ext('/foo.txt');
will return:
txt
This example:
path_ext('./foo.txt');
will return:
txt
This example:
path_ext('../foo.txt');
will return:
txt
This example:
path_ext('/foo/foo.txt');
will return:
txt
This example:
path_ext('/foo.bar.txt');
will return:
txt
This example:
path_ext('/foo/bar.');
will return:
This example will not return a defined value:
path_ext('/foo/bar');
This example will not return a defined value:
path_ext('.bashrc');
This example:
path_ext('.bashrc.tmp');
will return:
tmp
This example will not return a defined value:
path_ext('/no-dots');
See also "_normalize"
This example:
path_normalize('/');
will return:
/
This example:
path_normalize('/a/');
will return:
/a
This example:
path_normalize('/a/b/..');
will return:
/a
This example:
path_normalize('/a/../a');
will return:
/a
This example:
path_normalize('/a/../../a');
will return:
/a
This example:
path_normalize( "../../w/b/../s/x" );
will return:
../../w/s/x
This example:
path_normalize( "u/n/w/" );
will return:
u/n/w
This example:
path_normalize( "u/../w/b/../s" );
will return:
w/s
This example:
path_normalize( "u//n" );
will return:
u/n
This example:
path_normalize( "u//n/./f" );
will return:
u/n/f
This example:
path_normalize( "http://t/u//n" );
will return:
http://t/u/n
This example:
path_normalize( '/a/b/c/../../../d/e/f' );
will return:
/d/e/f
This example:
path_normalize( './a' );
will return:
./a
This example:
path_normalize( '/./a' );
will return:
/a
This example will not return a defined value:
path_parent('');
This example:
path_parent('/');
will return:
/
This example:
path_parent('/a');
will return:
/
This example:
path_parent('/a/b/..');
will return:
/
This example:
path_parent('a');
will return:
This example:
path_parent('a/b/');
will return:
a
This example:
path_parent('a/b.c');
will return:
a
This example:
path_parent('../../a');
will return:
../..
This example will not return a defined value:
path_name('');
This example:
path_name('/');
will return:
This example:
path_name('/a');
will return:
a
This example:
path_name('/a/b/..');
will return:
a
This example:
path_name('a/b/');
will return:
b
This example:
path_name('a/b.c');
will return:
b.c
This example will return true:
path_is_absolute('/a');
This example will return true:
path_is_absolute('A:/b');
This example will return true:
path_is_absolute('/a/b');
This example will return true:
path_is_absolute('http://a');
This example will return true:
path_is_absolute('svn+ssh://a.b');
This example will return false:
path_is_absolute('');
This example will return false:
path_is_absolute('a/b');
This example will return false:
path_is_absolute('a:\\b');
This example will return false:
path_is_absolute('a/../b');
This example will return false:
path_is_absolute('../a');
This example will return false:
path_is_absolute('./a');
This example will return false:
path_is_absolute('svn+ssh//a.b');
This example will return false:
path_is_absolute('1://');
This example will return false:
path_is_absolute('+://');
where:
@contents Items may be scalars or scalar references
returns:
1 when successful
dies if a handle cannot be obtained
where:
@contents Items may be scalars or scalar references
returns:
1 when successful
dies if a handle cannot be obtained
where:
$path # Absolute or relative file-system path
$mode r|w|rw # Read or write access (default 'r')
See also: File::Copy::copy
See also: File::Copy::move
This example will return true:
# normal usage
dir_is_system('.svn', '/tmp');
This example will return true:
# normal usage
dir_is_system('.git', '/tmp');
This example will return false:
# case sensitive
dir_is_system('.Svn', '/tmp');
This example will not return a defined value:
# undefined test
dir_is_system(undef, undef);
See also: File::Copy::move
This example:
FS('Node');
will return:
Data::Hub::FileSystem::Node
Ryan Gies <ryangies@cpan.org>
Copyright (C) 2014-2016 by Ryan Gies. All rights reserved.
Copyright (C) 2006-2013 by Livesite Networks, LLC. All rights reserved.
Copyright (C) 2000-2005 by Ryan Gies. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be
appreciated but is not required.
* Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
* The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
To the best of our knowledge, no patented algorithms have been used. However, we
do not have the resources to carry out a patent search, and therefore cannot
give any guarantee of the above statement.