wa2nlinux has asked for the wisdom of the Perl Monks concerning the following question:
The question is how can I put#!/usr/bin/perl use strict; use warnings; my @replace = ( [ qr/\/ka/ => '"ku"' ], [ qr/\/hi/ => '"he he he"' ], ); my $s = "/ka /hi"; for my $replace (@replace) { $s =~ s/$replace->[0]/$replace->[1]/gee; } open(FileHTM,">newfile") || die("Cannot Open File"); print FileHTM "$s\n"; close(FileHTM)
into a separate file because I need to write many more list on that. Also my @s (source text) should be a file too.my @replace = ( [ qr/\/ka/ => '"ku"' ], [ qr/\/hi/ => '"he he he"' ], );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find Replace text with list
by moritz (Cardinal) on Feb 07, 2011 at 07:55 UTC | |
by wa2nlinux (Novice) on Feb 07, 2011 at 14:35 UTC | |
by moritz (Cardinal) on Feb 07, 2011 at 14:41 UTC | |
by wa2nlinux (Novice) on Feb 07, 2011 at 15:13 UTC | |
by moritz (Cardinal) on Feb 07, 2011 at 15:29 UTC | |
| |
by Anonymous Monk on Feb 15, 2012 at 13:12 UTC | |
|
Re: Find Replace text with list
by roboticus (Chancellor) on Feb 07, 2011 at 13:10 UTC | |
by wa2nlinux (Novice) on Feb 08, 2011 at 02:37 UTC | |
by Anonymous Monk on Feb 08, 2011 at 07:27 UTC | |
by wa2nlinux (Novice) on Feb 09, 2011 at 01:53 UTC | |
by roboticus (Chancellor) on Feb 08, 2011 at 11:07 UTC |