From 773c964cfcf6ac6ce095ba46b98455b6e4be5e7b Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 20 Apr 2018 09:41:41 -0700 Subject: [PATCH] reuse the same null handle in globify_scalar --- Debbugs/Common.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index e16e78c..b135c42 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -1140,6 +1140,8 @@ before. This appears to be a bug in the underlying modules. =cut +our $_NULL_HANDLE; + sub globify_scalar { my ($scalar) = @_; my $handle; @@ -1164,8 +1166,15 @@ sub globify_scalar { else { carp "Given a non-scalar reference, non-glob to globify_scalar; returning /dev/null handle"; } + } + if (not defined $_NULL_HANDLE or + not $_NULL_HANDLE->opened() + ) { + $_NULL_HANDLE = + IO::File->new('/dev/null','>:encoding(UTF-8)') or + die "Unable to open /dev/null for writing: $!"; } - return IO::File->new('/dev/null','>:encoding(UTF-8)'); + return $_NULL_HANDLE; } =head2 cleanup_eval_fail() -- 2.39.2