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
This module requires these other modules and libraries:
Error::Simple File::Copy IO::File Parse::StringTokenizer Error::Programatic Perl::Module Fcntl Exporter Encode Data::Hub::Address IO::Dir
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
typeof('foo.bar', {});
data-hash
typeof('/with/path/foo.bar', []);
data-array
typeof('foo.bar', 'baz');
data-scalar-bar
my $addr = '/one/two/{/i/am/three}/four'; join(':', addr_shift($addr), addr_shift($addr), addr_shift($addr), addr_shift($addr));
one:two:{/i/am/three}:four
my $addr = '/one/two'; my $last = addr_pop($addr); "$last,$addr"
two,/one
See also "_normalize"
addr_normalize('/');
/
addr_normalize('/a/');
/a
addr_normalize('/a/b/..');
addr_normalize('/a/../b');
/b
addr_normalize('/a/../../b');
addr_normalize('/a/.../b');
addr_normalize('/a/.../');
addr_normalize('/a/...');
addr_normalize('/a/.../..');
addr_normalize('/a/../...');
This example will not return a defined value:
addr_parent();
addr_parent('');
addr_parent('/');
addr_parent('/a');
addr_parent('/a/b/..');
addr_parent('a/b/');
a
addr_parent('a/b.c');
addr_name('');
addr_name('/');
addr_name('/a');
addr_name('/a/b/..');
addr_name('a/b/');
b
addr_name('a/b.c');
b.c
scalar(addr_split(''));
0
join ' ', addr_split('/');
join ' ', addr_split('/a');
join ' ', addr_split('/a/b/..');
join ' ', addr_split('a/b/');
a b
join ' ', addr_split('a/b.c');
a b.c
addr_join('/');
addr_join('/a', '/');
addr_join('/a/', 'b/..');
addr_join('/a/..', '/b');
addr_join('/a/../', '../b');
addr_join('/a/.../', 'b');
addr_join('/a/', '.../');
addr_join('/a/', '...');
addr_join('/a/', 'b/');
/a/b
addr_join('/a/', 'b');
addr_join('/a', '/b');
addr_join('/a', 'b');
addr_join('/a', 'b', 'c');
/a/b/c
addr_ext(undef);
addr_ext('foo.txt');
txt
addr_ext('/foo.txt');
addr_ext('./foo.txt');
addr_ext('../foo.txt');
addr_ext('/foo/foo.txt');
addr_ext('/foo.bar.txt');
addr_ext('/foo/bar.');
addr_ext('/foo/bar');
addr_ext('.metadata');
addr_ext('.metadata.bak');
bak
addr_basename(undef);
addr_basename('/');
addr_basename('foo.txt');
foo
addr_basename('foo.txt/');
addr_basename('/foo.txt');
addr_basename('./foo.txt');
addr_basename('../foo.txt');
addr_basename('/foo/foo.txt');
addr_basename('/foo.bar.txt');
foo.bar
addr_basename('/foo/bar.');
bar
addr_basename('/foo/bar');
addr_basename('.metadata');
addr_basename('.metadata.bak');
.metadata
addr_base('/a/b/{d}');
addr_base('/a/b/d');
/a/b/d
my $path = '/one/two/../four'; join(':', path_shift($path), path_shift($path), path_shift($path), path_shift($path));
one:two:..:four
my $path = '/one/two'; my $last = path_pop($path); "$last,$path"
my $path = '/one/two'; my $count = path_push($path, 'three'); "$path"
/one/two/three
path_split('');
join ' ', path_split('/');
join ' ', path_split('/a');
join ' ', path_split('/a/b/..');
join ' ', path_split('a/b/');
join ' ', path_split('a/b.c');
path_basename(undef);
path_basename('foo.txt');
path_basename('/foo.txt');
path_basename('./foo.txt');
path_basename('../foo.txt');
path_basename('/foo/foo.txt');
path_basename('/foo.bar.txt');
path_basename('/foo/bar.');
path_basename('/foo/bar');
path_basename('.bashrc');
.bashrc
path_basename('.bashrc.tmp');
path_basename('/no-dots');
no-dots
path_ext(undef);
path_ext('foo.txt');
path_ext('/foo.txt');
path_ext('./foo.txt');
path_ext('../foo.txt');
path_ext('/foo/foo.txt');
path_ext('/foo.bar.txt');
path_ext('/foo/bar.');
path_ext('/foo/bar');
path_ext('.bashrc');
path_ext('.bashrc.tmp');
tmp
path_ext('/no-dots');
path_normalize('/');
path_normalize('/a/');
path_normalize('/a/b/..');
path_normalize('/a/../a');
path_normalize('/a/../../a');
path_normalize( "../../w/b/../s/x" );
../../w/s/x
path_normalize( "u/n/w/" );
u/n/w
path_normalize( "u/../w/b/../s" );
w/s
path_normalize( "u//n" );
u/n
path_normalize( "u//n/./f" );
u/n/f
path_normalize( "http://t/u//n" );
http://t/u/n
path_normalize( '/a/b/c/../../../d/e/f' );
/d/e/f
path_normalize( './a' );
./a
path_normalize( '/./a' );
path_parent('');
path_parent('/');
path_parent('/a');
path_parent('/a/b/..');
path_parent('a');
path_parent('a/b/');
path_parent('a/b.c');
path_parent('../../a');
../..
path_name('');
path_name('/');
path_name('/a');
path_name('/a/b/..');
path_name('a/b/');
path_name('a/b.c');
This example will return true:
path_is_absolute('/a');
path_is_absolute('A:/b');
path_is_absolute('/a/b');
path_is_absolute('http://a');
path_is_absolute('svn+ssh://a.b');
This example will return false:
path_is_absolute('');
path_is_absolute('a/b');
path_is_absolute('a:\\b');
path_is_absolute('a/../b');
path_is_absolute('../a');
path_is_absolute('./a');
path_is_absolute('svn+ssh//a.b');
path_is_absolute('1://');
path_is_absolute('+://');
where:
@contents Items may be scalars or scalar references
returns:
1 when successful dies if a handle cannot be obtained
$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
# normal usage dir_is_system('.svn', '/tmp');
# normal usage dir_is_system('.git', '/tmp');
# case sensitive dir_is_system('.Svn', '/tmp');
# undefined test dir_is_system(undef, undef);
FS('Node');
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.
To install Data::Hub, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Hub
CPAN shell
perl -MCPAN -e shell install Data::Hub
For more information on module installation, please visit the detailed CPAN module installation guide.