in reply to string replacement
Please edit your post to correct the formatting. See Markup in the Monastery. You should at least use <code> tags around your config file so that it can be displayed properly.
The "search and replace from a list of replacements" part can be done using a hash, and the substitution operator.
The pattern part is a regular expression if you don't know about them you can look at those tutorials.use strict; use warnings; my $text = "I will not stir from this place, do what they can."; my %replacements = ( "will not" => "won't", "stir" => "move", "this place" => "here", "do what they can" => "let them try"); my $pattern = join "|", map quotemeta, keys %replacements; print "The pattern is: $pattern\n"; my $replaced = $text =~ s/($pattern)/$replacements{$1}/gr; print $replaced;
As for reading your config file, one of the config modules might do what you want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: string replacement
by haukex (Archbishop) on Sep 12, 2017 at 18:57 UTC | |
by Eily (Monsignor) on Sep 12, 2017 at 20:44 UTC | |
|
Re^2: string replacement
by colox (Sexton) on Sep 13, 2017 at 16:06 UTC |