in reply to Re: modify the contents of an array
in thread modify the contents of an array

Hi, Your solution seems to be working perfectly but I am still wondering how it happened.I am a beginner in perl ,if you dont mind can you just explain me the solution

Replies are listed 'Best First'.
Re^3: modify the contents of an array
by Skeeve (Parson) on Sep 29, 2005 at 13:05 UTC
    No problem.

    The key thing is the regular expression (..)(?!$)
    This means: Match any 2 chars ".." and remember them "()" if they are not followed by the string's end "(?!$)".
    If such a match is found, it is replaced by the 2 chars found "$1" and a slash appended, so "$1/".
    Hmmm... Not so well my explanation, I think. The idea is to find any two characters and append a slash to them The only exception is at the end of the string where no slash may be added.

    This works well for your data, but as soon as you got other data, it will produce nonsense by inserting slashes every 2 characters.

    $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print
      Perhaps the issue is also one of readability, I had to do a double take because you used colons as regex delimiters. I'd use tall or fat ones, like '|' or '#'.