From: "William Martell" <[EMAIL PROTECTED]> > --------------------------------------------------------- > Hello Perl Users, > > I am curious whether there is a way to search a data store for a list > of values and if any of those values are matched, replace it with a > single common value. > > Currently, I can only use a Search and Replace engine to find and > replace a single value.
Suppose the list @strings contain the values you want to replace: my $regexp = join ('|', map {quotemeta $_} @strings); $regexp = qr/(?:$regexp)/; # # or # $regexp = qr/\b(?:$regexp)\b/; # # if you want the values to be matched only if they are complete # # words. That is if "cat" is supposed to match in # # "The cat sleeps.", but not in "concatenation". ... while (<INPUT>) { s/$regexp/single common value/g; ... } Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs