Skip to content

Commit aef568b

Browse files
committed
[Test-Harness] 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";
1 parent 58aaa5e commit aef568b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cpan/Test-Harness/lib/TAP/Harness.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ Any keys for which the value is C<undef> will be ignored.
494494
warn "CPAN::Meta::YAML required to process $rulesfile" ;
495495
return;
496496
}
497-
my $layer = $] lt "5.008" ? "" : ":encoding(UTF-8)";
497+
my $layer = "$]" < 5.008 ? "" : ":encoding(UTF-8)";
498498
open my $fh, "<$layer", $rulesfile
499499
or die "Couldn't open $rulesfile: $!";
500500
my $yaml_text = do { local $/; <$fh> };

0 commit comments

Comments
 (0)