in reply to character replace

First you will need to define what the difference is between "the character '&'" and "the entities". Then you will need to write a regular expression that replaces "the character '&'" but not "the entities".

Of you're talking about HTML, consider the following cases:

Meier &Cie Muller & Co Dowe, Cheatham &Howe, Attorneys Wallpapers&Paint;

Replies are listed 'Best First'.
Re^2: character replace
by sandy1028 (Sexton) on Jun 02, 2009 at 12:28 UTC
    All the entities are in the text file. If the & exists in a file it should not be replaced, it only & is there then it has to be replaced with &

      That's great. So now you can start writing your code.

      In case you haven't noticed so far, Perlmonks is not a code writing service. You are expected to write your code yourself. We will help you with specific problems you have in your code but we will not write your programs for you.

        #!/usr/bin/perl open FH,'ent.txt'; @data=<FH>; $text='&bush&amp;'; foreach $dat(@data){ $text =~ s/&/&amp;/g; print $text; }
        ent.txt file contains all the entities. This substitutes all the & with &