Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Can't modify int in scalar assignment error

by NetWallah (Abbot)
on Dec 19, 2012 at 05:25 UTC ( #1009496=note: print w/replies, xml ) Need Help??


in reply to Can't modify int in scalar assignment error

If you "use strict;" in your program, it would have told you:
Global symbol "@accums" requires explicit package name at ..
which identifies the problem immediately, in your "foreach(@accums)" line.

Poor programming practices precurse pernicious predicament.

             "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

Replies are listed 'Best First'.
Re^2: Can't modify int in scalar assignment error
by rkrish (Acolyte) on Dec 19, 2012 at 05:51 UTC

    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 :(

      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

      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.

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009496]
help
Chatterbox?
[planetscape]: sleep well, Corion
[stonecolddevin]: erix seems pretty good, i listened to "So Many Roads" and it was nice. Not everyone's cup of tea but this guy can absolutely shred, he and the guy from Mastodon are definitely up there: https://www. youtube.com/watch? v=VzhMkSN9dQc
[erix]: ha, good stuff - loud and fast...
[stonecolddevin]: here's some Mastodon for when you have 13 minutes to have your mind blown: https://www. youtube.com/watch? v=4pvfQtUhtNE

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-06-22 21:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.