From dfdbac242f29e6565ac6907d50c47b6f6cd8de0e Mon Sep 17 00:00:00 2001 From: "Philippe Bruhat (BooK)" Date: Fri, 13 Dec 2024 00:20:36 +0100 Subject: [PATCH] fix string comparisons with $] to use numeric comparison instead The fix follows Zefram's suggestion from https://www.nntp.perl.org/group/perl.perl5.porters/2012/05/msg186846.html > On older perls, however, $] had a numeric value that was built up using > floating-point arithmetic, such as 5+0.006+0.000002. This would not > necessarily match the conversion of the complete value from string form > [perl #72210]. You can work around that by explicitly stringifying > $] (which produces a correct string) and having *that* numify (to a > correctly-converted floating point value) for comparison. I cultivate > the habit of always stringifying $] to work around this, regardless of > the threshold where the bug was fixed. So I'd write > > use if "$]" >= 5.014, warnings => "non_unicode"; --- lib/TAP/Harness.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/TAP/Harness.pm b/lib/TAP/Harness.pm index b9156d45..3b07170e 100644 --- a/lib/TAP/Harness.pm +++ b/lib/TAP/Harness.pm @@ -494,7 +494,7 @@ Any keys for which the value is C will be ignored. warn "CPAN::Meta::YAML required to process $rulesfile" ; return; } - my $layer = $] lt "5.008" ? "" : ":encoding(UTF-8)"; + my $layer = "$]" < "5.008" ? "" : ":encoding(UTF-8)"; open my $fh, "<$layer", $rulesfile or die "Couldn't open $rulesfile: $!"; my $yaml_text = do { local $/; <$fh> };