Weird issue with PERL hashes on FreeBSD with EasyTimeline.pl that does not occur on RHEL 7.2

Anton Berezin tobez at tobez.org
Mon Oct 2 22:50:41 UTC 2017


Hello,

> On 2 Oct 2017, at 21:08, Crew <carborundumcrew at infogalactic.com> wrote:
> 
> An issue has turned up, seemingly with PERL hashes on FreeBSD 10.3-STABLE and 10.3-RELEASE-p21.
> 
> It involves a PERL script called EasyTimeline.pl. I have a simple reproducer that involves running EasyTimeline.pl with some ,input data (but you also need ploticus installed.)
> 
> When run on those two versions of FreeBSD the script will fail something like one out of five to seven times, but on RHEL 7.2 it never fails. On FreeBSD it will often fail the first time it is run, and then will succeed for the next five or so attempts and then fail again.
> 
> It seems to relate to one key in a hash being a proper prefix of another and the order in which the keys are in the hash. In this case the keys are "grid" and "gridcolor”.

In Perl, one cannot rely on any particular order while iterating a hash, so if something further down the line expects things to be in certain order, the script has to be modified to supply the correct order.
This has really nothing to do with FreeBSD.  Most likely it has something to do with the version of perl on those two platforms (which you have not specified), since, if I remember correctly, the order of hash keys during iteration (or the invocation of the “keys” operator) has been deliberately randomized in the more recent versions of perl interpreter.

Finally, there is “perl” the interpreter, and “Perl” the language.  There is no “PERL”.  This is important to some people.

Hope this helps,
\Anton.


More information about the freebsd-perl mailing list