Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Hash::Util: hash_seed in SYNOPSIS #17399

Closed
eserte opened this issue Dec 29, 2019 · 2 comments
Closed

[doc] Hash::Util: hash_seed in SYNOPSIS #17399

eserte opened this issue Dec 29, 2019 · 2 comments
Assignees

Comments

@eserte
Copy link
Contributor

eserte commented Dec 29, 2019

Where
Hash::Util SYNOPSIS

Description
The line

my $hashes_are_randomised = hash_seed() != 0;

does not work anymore for newer perls. Here's a oneliner test:

$ perl5.31.7 -MTest::More=no_plan -w -MHash::Util=hash_seed -e 'my $hashes_are_randomised = hash_seed() != 0; ok $hashes_are_randomised'      
Argument "�UM-^X4^VJ^I�VJ=aM-^T�Z�,}M-\foHM-^F�Y$" isn't numeric in numeric ne (!=) at -e line 1.
not ok 1
#   Failed test at -e line 1.
1..1
# Looks like you failed 1 test of 1.

What would work (also with older perls) is a regexp test like this:

$ perl5.31.7 -MTest::More=no_plan -w -MHash::Util=hash_seed -e 'my $hashes_are_randomised = hash_seed() !~ /^\0+$/; ok $hashes_are_randomised'
ok 1
1..1
@jkeenan
Copy link
Contributor

jkeenan commented Dec 29, 2019

perl5.31.7 -MTest::More=no_plan -w -MHash::Util=hash_seed -e 'my $hashes_are_randomised = hash_seed() !~ /^\0+$/; ok $hashes_are_randomised'

I'm not getting the results you anticipate with your suggested correction.

[v5.31.7] 591 $ ./bin/perl -Ilib -v | head -2 | tail -1
This is perl 5, version 31, subversion 7 (v5.31.7) built for x86_64-linux
[v5.31.7] 592 $ ./bin/perl -w -Ilib -MTest::More=no_plan -MHash::Util=hash_seed -e 'my $hashes_are_randomised = hash_seed() != 0; ok $hashes_are_randomized;'
Name "main::hashes_are_randomized" used only once: possible typo at -e line 1.
Argument "8^S��$����XM-^P^V4�^]�^A�M-^Z^[�1/M-^\^?��M-^P" isn't numeric in numeric ne (!=) at -e line 1.
not ok 1
#   Failed test at -e line 1.
1..1
# Looks like you failed 1 test of 1.
[v5.31.7] 593 $ ./bin/perl -w -Ilib -MTest::More=no_plan -MHash::Util=hash_seed -e 'my $hashes_are_randomised = hash_seed() !~ /^\0+$/; ok $hashes_are_randomized;'
Name "main::hashes_are_randomized" used only once: possible typo at -e line 1.
not ok 1
#   Failed test at -e line 1.
1..1
# Looks like you failed 1 test of 1.

What am I missing?

Thank you very much.
Jim Keenan

@eserte
Copy link
Contributor Author

eserte commented Dec 29, 2019

You are mixing American and British spelling (randomised vs. randomized).

jkeenan pushed a commit that referenced this issue Dec 29, 2019
jkeenan pushed a commit that referenced this issue Dec 30, 2019
@jkeenan jkeenan self-assigned this Dec 30, 2019
@jkeenan jkeenan closed this as completed Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants