Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing a substring in a text

Status
Not open for further replies.

truenight

Programmer
Oct 12, 2001
4
AU
Im trying to use the
$variable_name =~ s/[string_to_remove]/[string_to_add]

command to replace text found in an array.

Code below is direct excerpt from my code.
Code:
$emptyReplace = "($FORM{'elementName'})";
$empty = "EMPTY";
foreach $i (@xmlFileArray)
{
    if ($i =~ /$empty/)
    {
        @displayArray[$displayCount] =~ $i/$empty/emptyReplace/i;
        $displayCount ++;
    }
}
the text is in XML format and has been passed into an array for the program to modify. I know that the word im looking to replace. Which in this case is "empty" is in the file but when I later view the @displayArray the reference to empty has not been replaced.

Any suggestions as to why this is not working much appreciated.
 
Question Withdrawn error found unrelated to the code that was being pointed to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top