diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-09-08 17:41:51 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-09-08 17:41:51 +0000 |
commit | 47a02764cb8409fe0ace3dc31eb592db546bcef9 (patch) | |
tree | 02700ef274b893bdf17156320de13e44a4d678ba | |
parent | 821da36d9dc19d2cefe9e1a3edae000dd5b7b02d (diff) | |
download | perl-MDK-Common-47a02764cb8409fe0ace3dc31eb592db546bcef9.tar perl-MDK-Common-47a02764cb8409fe0ace3dc31eb592db546bcef9.tar.gz perl-MDK-Common-47a02764cb8409fe0ace3dc31eb592db546bcef9.tar.bz2 perl-MDK-Common-47a02764cb8409fe0ace3dc31eb592db546bcef9.tar.xz perl-MDK-Common-47a02764cb8409fe0ace3dc31eb592db546bcef9.zip |
(substInFile): automatic adding of "\n" for the last line if it's not "\n" terminated
-rw-r--r-- | MDK/Common/File.pm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm index 87923ee..9b6ee0b 100644 --- a/MDK/Common/File.pm +++ b/MDK/Common/File.pm @@ -135,7 +135,11 @@ sub substInFile(&@) { if (-s $file) { local @ARGV = $file; local ($^I, $_) = ''; - while (<>) { &$f($_); print } + while (<>) { + $_ .= "\n" if eof && !/\n/; + &$f($_); + print; + } } else { local *F; my $old = select F; # that way eof return true local $_ = ''; |