2 # Copyright 1999, 2000, 2001 Patrik Stridvall
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 use vars
qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
28 &append_file &edit_file &read_file &replace_file
29 &normalize_set &is_subset
34 ########################################################################
41 open(OUT
, ">> $filename") || die "Can't open file '$filename'";
42 my $result = &$function(\
*OUT
, @_);
48 ########################################################################
55 open(IN
, "< $filename") || die "Can't open file '$filename'";
56 open(OUT
, "> $filename.tmp") || die "Can't open file '$filename.tmp'";
58 my $result = &$function(\
*IN
, \
*OUT
, @_);
65 rename("$filename.tmp", "$filename");
67 unlink("$filename.tmp");
73 ########################################################################
80 open(IN
, "< $filename") || die "Can't open file '$filename'";
81 my $result = &$function(\
*IN
, @_);
87 ########################################################################
94 open(OUT
, "> $filename.tmp") || die "Can't open file '$filename.tmp'";
96 my $result = &$function(\
*OUT
, @_);
102 rename("$filename.tmp", "$filename");
104 unlink("$filename.tmp");
110 ########################################################################
121 foreach my $key (split(/\s*&\s*/)) {
125 return join(" & ", sort(keys(%hash)));
128 ########################################################################
135 foreach my $subitem (split(/ & /, $subset)) {
137 foreach my $item (split(/ & /, $set)) {
138 if($subitem eq $item) {