in reply to Problem Declaring a hash

You didn't show the whole (reduced) program, but my guess is that in line 25, your are missing a semicolon. When I have the following program:

#line 25 my $x = '123' = my %OCN_PFX_To_TDir=( 3085220111379778 => '3085220111379788_Rexx', 3085220334620644 => '3085220334620644_Spare', 3085220346432582 => '3085220346432582_Rexx2', 3085220352420034 => '3085220352420034_Algol' );

I get the error output

Can't modify constant item in scalar assignment at tmp.pl line 31, nea +r ");" Execution of tmp.pl aborted due to compilation errors.

So maybe your problem is some lines earlier.

If you can't spot it, copy the file and start removing lines until the error goes away. Then, if you still can't spot it, post the smallest version of your file that still reproduces the error. See also https://www.sscce.org/ - "smallest, self-contained example".

Replies are listed 'Best First'.
Re^2: Problem Declaring a hash
by The_Evil_One (Initiate) on Nov 07, 2025 at 02:09 UTC

    Much thanks Corion. Your answer is spot on, I looked at the preceding code and there was a declaration statement that lacked the terminating semi colon.

    Added the semi colon and it ran OK. It did not do anything because in deleting code to find possible problem sources I had deleted all active parts of the program.

    One other question. How do I mark my question solved?

    Regards TEO.

      one possibility is editing the subject of your original question to start with "[SOLVED]" or words to that effect,
      and possibly add some note for posterity¹, what the solution was (either as a reply, like you just did 👍, or as an update of the original post).

      ¹ i.e. others with a similiar problem 😉 [Update: typo/wrong paronym corrected, thanks hippo]