Hello Jimson,

Thursday, September 13, 2001, Jimson Lee <[EMAIL PROTECTED]> wrote:

[..]
JL> Being new to perl, I know how to search for strings.  I know how to
JL> explicitly search and replace a string.
you always can use variable instead of exact string.

JL>   What I don't know how to do is
JL> search for a string,
in array - grep, as you wrote below.
in string - match, see
perldoc -f m

JL>  make that string a variable,
grep function return array of results.
my @results = grep /OAM/i, @lines;

JL>  and then use that
JL> variable in a search and replace statement so that I can run this script
JL> at all my sites.
see
perldoc -f grep
(grep can do replace for you), or
perldoc -f s
perldoc perlop
JL> Here's what I'm using to search for a string...

JL> open FILE, "<config.cfg" or die "can't open config.cfg: $!";
JL> my @lines = <FILE>;
JL> print grep /OAM/i, @lines;

JL> When I run this against config.cfg, it gives me the string OAM...  Can I
JL> make that a variable?
yes :)

Best wishes,
 Maxim                            mailto:[EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to