From 64a5c34be02c3c8789809be2ebaea2ff2f78ea0e Mon Sep 17 00:00:00 2001
From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Thu, 10 Nov 2022 16:01:27 -0800
Subject: [PATCH] Fix rt #145095, undef warning in Perl before 5.12

`length(undef)` issues a warning on Perl older than 5.12.
---
 lib/Perl/Tidy/Formatter.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm
index 8252680a..cc4b02bd 100644
--- a/lib/Perl/Tidy/Formatter.pm
+++ b/lib/Perl/Tidy/Formatter.pm
@@ -2508,7 +2508,7 @@ sub initialize_trailing_comma_rules {
         $option =~ s/^\s+//;
         $option =~ s/\s+$//;
     }
-    if ( length($option) ) {
+    if ( defined($option) && length($option) ) {
         my $error_message;
         my %rule_hash;
         my @q = @{$rvalid_flags};
-- 
2.39.5