diff options
author | Peter Palfrader <peter@palfrader.org> | 2003-06-06 09:32:37 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2003-06-06 09:32:37 +0000 |
commit | 34eb364e3a9a9a7a47e82130a202aa147c49819f (patch) | |
tree | bb71c057d17b8cc365219a12a09326f1c715e636 /Echolot/Tools.pm | |
parent | d7ae02f539ef9ae38682ca81f768d4b6ab4ff4d7 (diff) |
Move read file from Stats to Tools
Diffstat (limited to 'Echolot/Tools.pm')
-rw-r--r-- | Echolot/Tools.pm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index 4426b86..fd86a4c 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -1,7 +1,7 @@ package Echolot::Tools; # (c) 2002 Peter Palfrader <peter@palfrader.org> -# $Id: Tools.pm,v 1.21 2003/02/28 17:10:57 weasel Exp $ +# $Id: Tools.pm,v 1.22 2003/06/06 09:32:37 weasel Exp $ # =pod @@ -349,6 +349,21 @@ sub make_garbage() { return $random; }; +sub read_file($;$) { + my ($name, $fail_ok) = @_; + + unless (open (F, $name)) { + Echolot::Log::warn("Could not open '$name': $!.") unless ($fail_ok); + return undef; + }; + local $/ = undef; + my $result = <F>; + close (F); + + return $result; +}; + + 1; # vim: set ts=4 shiftwidth=4: |