On Tue, 29 May 2001, prachi shroff wrote:

> I am having problems using the "s///" operator for substitution in of a
> particular pattern in a specified file.
> For eg.
>
> open(TRY,"+<try.txt");
> while(<TRY>)
> {
>       $_ =~ s/a/p/g;
> }

This does nothing to your file.  You need to write your data back out to a
temp file (or use the -i command-line switch) and copy the temp file to
the correct name.  There was a big thread last week on editing files in
place.  You might want to look back at the archives at
http://archive.develooper.com/beginners%40perl.org/ to see some different
options for editing files in place.

BTW, saying '$_ =~' in your code above is unnecessary because by default
the substition operator will match against $_.

-- Brett

Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]

Reply via email to