| Config-Manager documentation | view source | Contained in the Config-Manager distribution. |
Config::Manager::File - Basic File Utilities (for Tools)
use Config::Manager::File
qw(
Normalize
MakeDir
UniqueTempFileName
ConvertFromHost
ConvertToHost
CompareFiles
CopyFile
MoveByCopying
MD5Checksum
ReadFile
WriteFile
AppendFile
ConvertFileWithCallback
SerializeSimple
Semaphore_Passeer
Semaphore_Verlaat
GetNextTicket
);
use Config::Manager::File qw(:all);
$dir = Normalize($dir);
($drv,$dir) = Normalize($dir);
$error = MakeDir($dir);
$tempfilename = &UniqueTempFileName();
&ConvertFromHost($targetfile,$sourcefile,$linenumbering,$purgeblanks);
&ConvertToHost($targetfile,$sourcefile,$linenumbering,$purgeblanks,$checklength);
$same = &CompareFiles($file1,$file2);
&CopyFile($source,$target);
&MoveByCopying($source,$target);
$checksum = &MD5Checksum($source);
$arrayref = &ReadFile($source);
&WriteFile($target,@contents);
&AppendFile($target,$source);
&ConvertFileWithCallback($target,$source,$callback);
$printable = &SerializeSimple("varname",$datastructure);
Semaphore_Passeer($lockfile);
Semaphore_Verlaat($lockfile);
$ticket = GetNextTicket($lockfile,$ticketfile,$count_min,$count_max);
$dir = Normalize($dir);
($drv,$dir) = Normalize($dir);
"$drive/$path".
(Again, the "drive" will be a dot (".") if the path is
relative.)
$error = MakeDir($dir);
$tempfilename = &UniqueTempFileName();
.tmp".
&ConvertFromHost($targetfile,$sourcefile,$linenumbering,$purgeblanks);
$targetfile" is given) is written instead.
$targetfile" must be a valid filename; beware that it will
be overwritten if it already exists!
$sourcefile" is the input file's name (and path),
"$linenumbering" is a flag (0 = "no", 1 = "yes")
indicating whether line numbers shall be removed from the
beginning of each line, and "$purgeblanks" is a flag
(0 = "no", 1 = "yes") indicating whether trailing whitespace
is to be purged from each line.
$linenumbering" option is enabled, or if there was a
problem closing the input file, or if a needed configuration constant
was unavailable. &ConvertToHost($targetfile,$sourcefile,$linenumbering,$purgeblanks,$checklength);
$targetfile" is given) is written instead.
$targetfile" must be a valid filename; beware that it will
be overwritten if it already exists!
$sourcefile" is the input file's name (and path),
"$linenumbering" is a flag (0 = "no", 1 = "yes")
indicating whether line numbers shall be prepended to
each line, "$purgeblanks" is a flag (0 = "no",
1 = "yes") indicating whether trailing whitespace is to
be removed from each line, and "$checklength" is
a flag (0 = "no", 1 = "yes") signaling whether lines
should be checked for correct length (a warning message
will be issued if the maximum COBOL line length (66 columns)
is exceeded by any line).
$same = &CompareFiles($file1,$file2);
&CopyFile($source,$target);
$source" to "$target". Returns "true" (1) on success
and "undef" in case of any error.
&MoveByCopying($source,$target);
$source" to "$target", then deletes file
"$source" if the copy was successful. Returns "true" (1)
on success and "undef" in case of any error.
$checksum = &MD5Checksum($source);
$source". Returns the checksum
(a 16 digit hexadecimal string) on success and "undef" in case of any error.
$file" contains the name and path of the
file in question, and "$checksum" contains its checksum):
if (defined $filesig{-s $file}{$checksum})
{
# file already known
}
else
{
# file not encountered yet
}
$filesig{-s $file}{$checksum}{$file} = 1; # add file to list
$arrayref = &ReadFile($source);
$/" is set to "\n" (line mode)
locally before the file is read).
&WriteFile($target,@contents);
@msg = (); push( @msg, "1st line\n" ); push( @msg, "2nd line\n" ); &WriteFile( $target, "Messages:\n\n", \@msg );
&AppendFile($target,$source);
$source" to file "$target" using binary mode.
&ConvertFileWithCallback($target,$source,$callback);
$source" is read line by line (the input separator "$/"
is set to "\n" (line mode) locally before the file is opened), and for
each line, a callback function (provided by you) is called.
$target" file,
provided that the return value is not "undef". If the callback function's
return value is "undef", nothing is printed to the output file. (This way,
you can delete certain lines from a file!)
$cb = sub { my($l) = @_; $l =~ s!\s+$!!; "$l\n"; };
&ReportErrorAndExit unless
(defined &ConvertFileWithCallback($target,$source,$cb));
$printable = &SerializeSimple("varname",$datastructure);
WriteFile()" function, which will
automatically write the lines in the array to the indicated
file.
\n") at the end of each line.
require" or "eval".
Semaphore_Passeer($lockfile);
Semaphore_Verlaat($lockfile);
$ticket = GetNextTicket($lockfile,$ticketfile,$min,$max);
$min" value given).
$max" value, it
is reset to "$min" (i.e., the function implements automatic
wrapping).
Config::Manager(3), Config::Manager::Base(3), Config::Manager::Conf(3), Config::Manager::PUser(3), Config::Manager::Report(3), Config::Manager::SendMail(3), Config::Manager::User(3).
This man page documents "Config::Manager::File" version 1.7.
Steffen Beyer <sb@engelschall.com> http://www.engelschall.com/u/sb/download/ Gerhard Albers
Copyright (c) 2003 by Steffen Beyer & Gerhard Albers. All rights reserved.
This package is free software; you can use, modify and redistribute it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".
Please refer to the files "Artistic.txt" and "GNU_GPL.txt" in this distribution, respectively, for more details!
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the "GNU General Public License" for more details.
| Config-Manager documentation | view source | Contained in the Config-Manager distribution. |