The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Meta::Utils::File::File - library to do operations on files.

COPYRIGHT

Copyright (C) 2001 Mark Veltzer; All rights reserved.

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program 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.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.

DETAILS

MANIFEST: File.pm PROJECT: meta

SYNOPSIS

package foo; use Meta::Utils::File::File qw(); my($file)="/etc/passwd"; if(Meta::Utils::File::File::exist($file)) { # try to break into the system } else { # we are in windows, just remove the kernel.dll from c:\windows }

DESCRIPTION

This is a library to help you do things with files with meaningful names. For instance: check if a file exists, compare two files etc...

EXPORTS

check_mult_regexp($$$) check_sing_regexp($$$) save_nodie($$) save($$) load_nodie($$) load($) load_line($$) cmp($$) exist($) notexist($) check_exist($) check_notexist($) create_new($) subst($$$)

FUNCTION DOCUMENTATION

check_mult_regexp($$$)

This routine does exactly the same as check_sing_regexp except it gets a list of regular expressions and matches any of them. This also receives a variable telling it whether to print the matched lines or not.

check_sing_regexp($$$)

This routine checks whether a single regular expression given to it is present in the file given to it. This also receives a variable telling it whether to print the matched lines or not.

save_nodie($$)

This does exactly the same as save but does not die if something goes wrong and instead returns a valid error bit.

save($$)

This routine receives a file name and text to write into it. The routine assumes that it has permissions, and writes a new file (recreates it) and writes the string into it, and then closes the file. The routine dies if something goes wrong.

load_nodie($$)

This routine receives a file name and a reference to a string. The routine loads the file into the string. If the routine fails somewhere then it return a valid error bit.

load($)

This routine loads up a files into a single string and gives it to you. Currently it just loads up the file line by line and catenates them into a variable.

load_line($$)

This routine loads a specific text line from the source file given to it. You better make sure that the specified file has that line in it..!!!:)

cmp($$)

This routines receives a file to compare a variable with. It returns a boolean value which is the result of the comparison. The implementation attemps to read length(input) characters from the file. If it fails it return false and else it just does a eq comparison...

exist($)

This routine returns whether a cetain file is a regular file

notexist($)

This routine returns whether a certain file not exist as a regular file

check_exist($)

This routine checks if a file given to it exists and if indeed it is a regular file. If something fails it dies.

check_notexist($)

This routine checks if a file given to it not exists. If something fails it dies.

create_new($)

This function receives a file name and creates that file (it supposes the file does not exist and if it does it fails...).

subst($$$)

This function receives the following arguments: 1. File to be modifield. 2. Pattern to be searched for. 3. Pattern to be replaced with. And modifies the file by replacing the required pattern with the target pattern.

BUGS

None.

AUTHOR

Mark Veltzer <mark2776@yahoo.com>

HISTORY

start of revision info 1 Mon Jan 1 16:38:12 2001 MV initial code brought in 2 Thu Jan 4 06:30:32 2001 MV this time really make the databases work 3 Sat Jan 6 11:39:39 2001 MV make quality checks on perl code 4 Sat Jan 6 17:14:09 2001 MV more perl checks 5 Sun Jan 7 18:17:29 2001 MV make Meta::Utils::Opts object oriented 6 Tue Jan 9 18:15:19 2001 MV check that all uses have qw 7 Tue Jan 9 19:29:31 2001 MV fix todo items look in pod documentation 8 Wed Jan 10 12:05:55 2001 MV more on tests/more checks to perl 9 Thu Jan 18 15:59:13 2001 MV correct die usage 10 Sun Jan 28 02:34:56 2001 MV perl code quality 11 Sun Jan 28 13:51:26 2001 MV more perl quality 12 Tue Jan 30 03:03:17 2001 MV more perl quality 13 Sat Feb 3 23:41:08 2001 MV perl documentation 14 Mon Feb 5 03:21:02 2001 MV more perl quality 15 Tue Feb 6 01:04:52 2001 MV perl qulity code 16 Tue Feb 6 07:02:13 2001 MV more perl code quality 17 Tue Feb 6 22:19:51 2001 MV revision change end of revision info

SEE ALSO

Nothing.

TODO

-Can we do the file load function in a more efficient way ? (like first getting the size of the file and the gulping it down?).

-Cant the load() fundtion return a reference to the data instead of the actual data ? (the return value may be long...). (The same goes for load_line...).

-Do the create_new function more effiently (isnt there a perl function for it?).

-make the load routine prototype be the same as the load_nodie prototype. (its cleaner that way...).