summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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