Click here to get back home

Help: Replace Help

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Help: Replace Help Amy Lee 05-01-2008
Posted by A. Sinan Unur on May 1, 2008, 10:50 pm
Please log in for more thread options
benkasminbullock@gmail.com (Ben Bullock) wrote in

>
>> Well, if one uses the solution you proposed above and the list of
>> data to swap changes to
>>
>> my %subst = qw( A|C C|A G|U U|G );
>>
>> there will be issues with the way you build the search string.
>
>> my $search = join ('|', map { "(?:\Q$_\E)" } keys %replace);
>
> So you agree that the lookup table driven solution isn't simple?
>
> I think my original method of substituting in an unlikely string,
> which you objected to, was fairly appropriate for this particular
> question. I often use this kind of method for quick jobs.

Yes. That was the first thing in my response: 'Granted'.

OTOH, the number of repeated substitution operations which the 'unlikely
string' approach requires (especially as the number of
lookups/replacements grows) makes me think that the more complex
approach might end up being simpler to maintain for any 'durable'
program.

Thank you for your corrections.

Sinan

--
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

Similar ThreadsPosted
s/$match/$replace/ fails when $replace has backreferences September 5, 2005, 7:05 pm
Replace with nothing May 12, 2005, 7:54 am
HOW TO replace ' but not ?' October 27, 2004, 4:30 pm
search & replace September 7, 2004, 12:27 pm
search and replace help April 22, 2005, 2:11 am
searc and replace April 22, 2005, 3:10 am
search and replace September 2, 2005, 6:12 am
match 1/2/3, replace with a/b/c October 15, 2005, 10:30 am
Search and Replace December 6, 2005, 3:41 am
Search and Replace May 24, 2006, 8:11 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap