in reply to Tests were run but no plan was declared and done_testing() was not seen.

t/00-load.t line 95, near "$hashRefOutput;
This is line 95:
my @gotHashRefKeys = keys $hashRefOutput;
I'm using Perl version 5.12, and I get this error. My version of keys shows:
keys HASH keys ARRAY

The latest docs also support keys EXPR:

Starting with Perl 5.14, keys can take a scalar EXPR, which must contain a reference to an unblessed hash or array.
This test is not portable across all versions run by CPANTesters.

Replies are listed 'Best First'.
Re^2: Tests were run but no plan was declared and done_testing() was not seen.
by choroba (Cardinal) on Jul 10, 2015 at 23:35 UTC
    You can use Syntax::Construct to find out, or even to tell Perl and fellow programmers reading your code:
    use Syntax::Construct qw{ auto-deref };
    End of blatant boasting plug
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Syntax::Construct looks like a useful tool. All useful tools should be promoted.

      However, after reading the POD, it is not clear to me why I should use it. I understand that I can add this line to a Perl file...

      use Syntax::Construct qw( // ... /r );
      and it will give me a message like:
      Unsupported construct /r at ... line ... (Perl 5.014)
      I am running on Perl version 5.12. Is this telling me that the /r construct was added in Perl version 5.014? If so, I find that very helpful. However, can you elaborate on the qw( // ... /r )? It's not clear from the POD why you chose that. Is that guaranteed to cover all the constructs supported by the module?

      Regarding use Syntax::Construct qw{ auto-deref };, if I am using 5.14 (which supports keys EXPR), does this alter the behavior of my code with keys $foo?

        The answer to your first question is Yes. Maybe I should add "needed" after the version?

        The three constructs shown in the Synopsis are the ones needed in the example code there. It's the programmer's responsibility to track them and list them. So yes, the human factor is the weakest part of the system.

        Under 5.14, keys $ref already work without any switch. Specifying use Syntax::Construct qw{ auto-deref }; wouldn't change anything for you running on 5.14 (or higher), but it would give meaningful error messages to you or anyone else trying to run it on 5.12 and below. For keys $ref, the default message isn't so bad:

        Type of arg 1 to keys must be hash (not scalar dereference)

        but for example for $x //= 1, I'm getting

        Search pattern not terminated

        in 5.8.3.

        It's in fact a triple-win situation:

        1. You win as the programmer, as you have all the constructs in one place (i.e. Syntax::Construct's documentation) and you don't waste your time searching through perldeltas and other places.
        2. Users of your modules win as they get meaningful error messages telling them to what Perl version they need to upgrade.
        3. The programmer they hired to workaround the problem wins as they know what constructs to replace in the code to make it run in the ancient version.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^2: Tests were run but no plan was declared and done_testing() was not seen.
by thanos1983 (Parson) on Jul 10, 2015 at 19:37 UTC

    Hello toolic,

    Once more you nailed it ;)

    I will update the module asap, I am also planning to update the documentation, it looks funny to me. :D

    Again, thank you for your time and effort I appreciate it.

    Seeking for Perl wisdom...on the process of learning...not there...yet!