Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Problem Declaring a hash

by Corion (Patriarch)
on Nov 05, 2025 at 20:39 UTC ( [id://11166655]=note: print w/replies, xml ) Need Help??


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]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11166655]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2026-01-13 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (118 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.