in reply to Same problem replacing array index numbers

Multiple problems here.
  1. $OldVariable contains characters special to the regexp engine -- prepend with \Q.
  2. The random number may be repeated.
  3. Once you've modified $code, @code isn't updated.
  4. Your code doesn't deal with multiple arrays on a line.
  5. The sigil for (scalar) array access is $, not @.
  6. You aren't modifying any arrays that aren't indexed (for instance, your code leaves my @array untouched).
  7. You're assuming there's no space between the array name and the index.
  8. You're assuming the index consists of just a number, what if it's an expression, a variable, or has whitespace?
  9. You're missing all the arrays containing capital letters, or that start with an underscore.

Replies are listed 'Best First'.
Re^2: Same problem replacing array index numbers
by astroid96 (Initiate) on Apr 11, 2012 at 15:03 UTC
    i'm aware of some of these problem thats where i need help :) all of the assumptions are people i will be the person who makes the files that are to be modified its for personal use.:) thanks