in reply to syntax error

You get a syntax error from Perl because 1586iY2vSfT5EeuQTMYj6kwnbfN255KX2T is not a hash key you can use unquoted. That's why Perl says it found a "bareword".

Quote your hash key and the error goes away.

Replies are listed 'Best First'.
Re^2: syntax error
by LanX (Saint) on Jun 20, 2017 at 15:11 UTC
    I never realized that auto-quoting of keys depends on identifier rules.

    Identifiers are not allowed to start with digits, like it's not allowed to call a

    sub 1586i { ... }

    UPDATE:

    though it's possible to have a pure digit key (?)

    DB<113> p $h{1586}++ 1 DB<114> p $h{1586}++ 2

    strange ...

    Update

    so I couldn't find it documented, but the rule seems to be:

    In order to autoquote a hash key it has to be a legal identifier or a number.

    in this case the number is found and Perl thinks an operator is missing to separate it from the bareword.

    from perlglossary

    identifier

    A legally formed name for most anything in which a computer program might be interested. Many languages (including Perl) allow identifiers to start with an alphabetic character, and then contain alphabetics and digits. Perl also allows connector punctuation like the underscore character wherever it allows alphabetics. (Perl also has more complicated names, like qualified names.)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      See my post here for a lot of examples and explanation :-) In short, from perldata:

      ... a simple identifier within such curlies is forced to be a string, and likewise within a hash subscript. Neither need quoting. ... This means for example that $version{2.0}++ is equivalent to $version{2}++, not to $version{'2.0'}++.

      $h{1586} works because it's interpreted as an integer, so something like $h{0+1586}, which stringifies to "1586".

Re^2: syntax error
by bigup401 (Pilgrim) on Jun 20, 2017 at 15:16 UTC

    thanks it worked when i added quote