summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOliver Tappe2008-02-01 20:33:32 +0100
committerOliver Tappe2008-02-01 20:33:32 +0100
commitb7206d9bed206bc8b27c57cc1fab488d12594b2d (patch)
treeb34ce6c02cb0e929bc80f9b32800c9d12c36f83d /lib
parent* warnings are now indicated by '°°°', errors by '***' (diff)
downloadcore-b7206d9bed206bc8b27c57cc1fab488d12594b2d.tar.gz
core-b7206d9bed206bc8b27c57cc1fab488d12594b2d.tar.xz
core-b7206d9bed206bc8b27c57cc1fab488d12594b2d.zip
* slurpFile now supports returning the file as an array of lines
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1507 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib')
-rw-r--r--lib/OpenSLX/Utils.pm18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm
index a47a1ea7..d66cde19 100644
--- a/lib/OpenSLX/Utils.pm
+++ b/lib/OpenSLX/Utils.pm
@@ -109,16 +109,24 @@ sub slurpFile
= exists $flags->{failIfMissing} ? $flags->{failIfMissing} : 1;
my $ioLayer = $flags->{'io-layer'} || 'utf8';
- local $/;
my $fh;
if (!open($fh, "<:$ioLayer", $fileName)) {
return '' unless $failIfMissing;
croak _tr("could not open file '%s' for reading! (%s)", $fileName, $!);
}
- my $content = <$fh>;
- close($fh)
- or croak _tr("unable to close file '%s' (%s)\n", $fileName, $!);
- return $content;
+ if (wantarray()) {
+ my @content = <$fh>;
+ close($fh)
+ or croak _tr("unable to close file '%s' (%s)\n", $fileName, $!);
+ return @content;
+ }
+ else {
+ local $/;
+ my $content = <$fh>;
+ close($fh)
+ or croak _tr("unable to close file '%s' (%s)\n", $fileName, $!);
+ return $content;
+ }
}
sub spitFile