Fink::Command(3) Fink documentation Fink::Command(3)NAMEFink::Command - emulate common shell commands in Perl
SYNOPSIS
use Fink::Command ':ALL';
mv @src, $dest;
cp @src, $dest;
my $text = cat $file;
my @text = cat $file;
mkdir_p @dirs;
rm_rf @dirs;
rm_f @files;
touch @files;
chowname $user, @files;
symlink_f $src, $dest;
DESCRIPTION
Its a common tempation to write something like this:
execute("rm -rf $dir");
Instead of relying on shell utilities, we can do this inside Perl.
This module provides a set of Perl functions emulating common shell
utilities.
Functions
No functions are exported by default, they are all optional. You can
get all of them with
use Fink::Command ':ALL';
Unless noted otherwise, functions set $! and return false on failure.
mv
mv $src, $dest;
mv @srcs, $destdir;
Like "mv".
cp
cp $src, $dest;
cp @srcs, $destdir;
Like "cp".
cat
my $text = cat $file;
my @text = cat $file;
Reads a file returning all the text in one lump or as a list of
lines depending on context.
Returns undef on error, even in list context.
mkdir_p
mkdir_p @dirs;
Like "mkdir -p".
Due to an implementation quirk, $! is not set on failure.
If this becomes a problem, reimplement without File::Path
rm_rf
rm_rf @dirs;
Like "rm -rf"
rm_f
rm_f @files;
Like "rm -f"
touch
touch @files;
Like "touch".
chowname
chowname $user, @files;
chowname "$user:$group", @files;
chowname ":$group", @files;
Like "chowname" but the user/group specification is a bit simpler,
since it takes user/group names instead of numbers like the the
Unix "chown" command. Either (or both) can be omitted, in which
case that parameter is not changed. Dot is not supported as a
separator.
chowname_hr
chowname_hr $user, @files;
chowname_hr "$user:$group", @files;
chowname_hr ":$group", @files;
Like chowname, but recurses down each item in @files. Symlinks are
not followed.
symlink_f
symlink_f $src, $dest;
Like "ln -sf". Currently requires the full filename for $dest (not
just target directory.
du_sk
du_sk @dirs;
Like "du -sk", though slower.
On success returns the disk usage of @dirs in kilobytes. This is
not the sum of file-sizes, rather the total size of the blocks
used. Thus it can change on a filesystem with support for sparse
files, or an OS with a different block size.
On failure returns "Error: <description>".
SEE ALSO
This module is inspired by ExtUtils::Command
Fink 0.36.3.1 2013-12-30 Fink::Command(3)