Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Can't modify int in scalar assignment error

by rkrish (Acolyte)
on Dec 19, 2012 at 05:51 UTC ( #1009500=note: print w/ replies, xml ) Need Help??


in reply to Re: Can't modify int in scalar assignment error
in thread Can't modify int in scalar assignment error

I have not used 'use strict' in my code. I just tried using it,it gave lot of such messages :( "Global symbol "@accums" requires explicit package name at " Please throw some light on how to fix this :(


Comment on Re^2: Can't modify int in scalar assignment error
Re^3: Can't modify int in scalar assignment error
by 2teez (Priest) on Dec 19, 2012 at 06:16 UTC

    see strict

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me
Re^3: Can't modify int in scalar assignment error
by NetWallah (Monsignor) on Dec 19, 2012 at 06:30 UTC
    Aside from logic problems, you have a "scope" problem with your "@accum" variable.

    You have declared it in the "while (my @accum=...)" statement, which makes it local to the while loop.

    You attempt to use it outside the while loop (where it does not exist), in the "foreach" statement.

    To correct the problem, the preferred method is to fix your logic.

    If you do not understand what your logic problem is, use globals, and suffer later.

    If you do not understand what I'm trying to say, please read up on variable scoping, and algorithms (these topics are fairly independent of the programming language you choose).

                 "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius

Re^3: Can't modify int in scalar assignment error
by roboticus (Canon) on Dec 19, 2012 at 13:05 UTC

    rkrish:

    If you add use diagnostics;, it will give more detailed error messages, and suggestions on what the problem is and/or potential fix(es) (IIRC).

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-04-18 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (466 votes), past polls