Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Adding scalars but with a twist..

by Corion (Patriarch)
on Feb 13, 2005 at 09:44 UTC ( #430557=note: print w/replies, xml ) Need Help??

in reply to Adding scalars but with a twist..

Put them in an array instead and use that. This is one of the reasons why everybody told you in your previous post that it's not a good thing to want to get at a variable through a second variable by its name.

Replies are listed 'Best First'.
Re^2: Adding scalars but with a twist..
by snappybo (Initiate) on Feb 13, 2005 at 15:12 UTC
    Ok i'd love to, except there's about 500,000 lines of code previously written by someone else. (badly). Trust me this is not the way i'd normal write things but am forced to..
    Unfortunately whoever wrote this previously was terrible and it's just easier to keep running along thier lines, the reasons i'm asking the questions is i would never write a program like this but have to as small additions are being made.

    I.e. everywhere through the code it has $Sel1Ttl + $Sel2Ttl......$Sel80Ttl already written..

    Now everyone in thier answers has concentrated on the addition of the values, where the real problem is the $SelMaking this number changeTtl part...

      I guess some heavy refactoring is needed then. Should not be that hard to search&replace all the /\$Sel(\d+)Ttl\b/ with "$SelTtl\[$1]". Of course you should then go and replace those insane $Sel1Ttl + $Sel2Ttl......$Sel80Ttl, by sum(@SetTtl) (from List::Util), but that's something that can wait if necessary.

      We'd like to help you learn to help yourself
      Look around you, all you see are sympathetic eyes
      Stroll around the grounds until you feel at home
         -- P. Simon in Mrs. Robinson

      except there's about 500,000 lines of code
      In a single script? Assuming an average length of 40 Bytes per line that would be 19 MB!

      holli, /regexed monk/
        about 12Mb, it's awful!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-05-28 20:38 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (101 votes). Check out past polls.