Subject: | Spurious "uninitialized value" warnings |
The attached patch suppresses some "uninitialized value" warnings in Text::Typography.
Thanks.
Subject: | warnings.diff |
From c0bf6aa9cdf106d4477b3666c9a06c1143a5d777 Mon Sep 17 00:00:00 2001
From: Aaron Crane <arc@cpan.org>
Date: Sun, 26 Aug 2012 15:14:52 +0100
Subject: [PATCH] Suppress "uninitialized value" warnings
If an optional capturing group is missing in the input, $1 will be
undef. In this case, $1 was then being used in the right-hand side of
an s///, which then produced the warning. Fix this by instead having
a required capturing group, optionally containing the appropriate thing.
---
lib/Text/Typography.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/Text/Typography.pm b/lib/Text/Typography.pm
index 6da4dd8..de9eb72 100644
--- a/lib/Text/Typography.pm
+++ b/lib/Text/Typography.pm
@@ -540,7 +540,7 @@ sub EducateQuotes {
} {$1‘}xg;
# Single closing quotes:
s {
- ($close_class)?
+ ($close_class?)
'
(?(1)| # If $1 captured, then do nothing;
(?=\s | s\b) # otherwise, positive lookahead for a whitespace
@@ -569,7 +569,7 @@ sub EducateQuotes {
# Double closing quotes:
s {
- ($close_class)?
+ ($close_class?)
"
(?(1)|(?=\s)) # If $1 captured, then do nothing;
# if not, then make sure the next char is whitespace.
--
1.7.11.3