summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-08-01 16:31:56 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-08-01 16:31:56 +0000
commitf5e651fb4603ec1caaabd976e4088e60156c8fdd (patch)
tree07036dd56fd22a31f715c608adae2ad67229c625 /MDK
parentab2b02f3349dbf1960f2af5b43295d1ffa6be040 (diff)
downloadperl-MDK-Common-f5e651fb4603ec1caaabd976e4088e60156c8fdd.tar
perl-MDK-Common-f5e651fb4603ec1caaabd976e4088e60156c8fdd.tar.gz
perl-MDK-Common-f5e651fb4603ec1caaabd976e4088e60156c8fdd.tar.bz2
perl-MDK-Common-f5e651fb4603ec1caaabd976e4088e60156c8fdd.tar.xz
perl-MDK-Common-f5e651fb4603ec1caaabd976e4088e60156c8fdd.zip
- File.pm: add "append_to_file"
- perl_checker: a few more stricter rules
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common.pm.pl3
-rw-r--r--MDK/Common/File.pm7
2 files changed, 8 insertions, 2 deletions
diff --git a/MDK/Common.pm.pl b/MDK/Common.pm.pl
index 304ea49..b5e7f6e 100644
--- a/MDK/Common.pm.pl
+++ b/MDK/Common.pm.pl
@@ -1,6 +1,8 @@
print <<'EOF';
+package MDK::Common;
+
=head1 NAME
MDK::Common - miscellaneous functions
@@ -55,7 +57,6 @@ modify it under the same terms as Perl itself.
=cut
-package MDK::Common;
use MDK::Common::DataStructure qw(:all);
use MDK::Common::File qw(:all);
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm
index 413dfa6..208fd1c 100644
--- a/MDK/Common/File.pm
+++ b/MDK/Common/File.pm
@@ -34,6 +34,10 @@ array context it returns the lines
creates a file and outputs the list (if the file exists, it is clobbered)
+=item append_to_file(FILENAME, LIST)
+
+add the LIST at the end of the file
+
=item output_p(FILENAME, LIST)
just like C<output> but creates directories if needed
@@ -101,7 +105,7 @@ L<MDK::Common>
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK);
@ISA = qw(Exporter);
-@EXPORT_OK = qw(dirname basename cat_ cat__ output output_p linkf symlinkf renamef mkdir_p rm_rf cp_af touch all glob_ substInFile expand_symlinks openFileMaybeCompressed catMaybeCompressed);
+@EXPORT_OK = qw(dirname basename cat_ cat__ output output_p append_to_file linkf symlinkf renamef mkdir_p rm_rf cp_af touch all glob_ substInFile expand_symlinks openFileMaybeCompressed catMaybeCompressed);
%EXPORT_TAGS = (all => [ @EXPORT_OK ]);
sub dirname { local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' }
@@ -109,6 +113,7 @@ sub basename { local $_ = shift; s|/*\s*$||; s|.*/||; $_ }
sub cat_ { local *F; open F, $_[0] or return; my @l = <F>; wantarray ? @l : join '', @l }
sub cat__ { my ($f) = @_; my @l = <$f>; wantarray ? @l : join '', @l }
sub output { my $f = shift; local *F; open F, ">$f" or die "output in file $f failed: $!\n"; print F foreach @_ }
+sub append_to_file { my $f = shift; local *F; open F, ">>$f" or die "output in file $f failed: $!\n"; print F foreach @_ }
sub output_p { my $f = shift; mkdir_p(dirname($f)); output($f, @_) }
sub linkf { unlink $_[1]; link $_[0], $_[1] }
sub symlinkf { unlink $_[1]; symlink $_[0], $_[1] }