Thanks for the reply.
I will try that (modifying the for loop).
I also tried to figure out if it was
just the loop, or the replacement text
that was giving me problems.
For example, I changed my $new_ptrn to
equal 'foo' and things worked okay.
When I changed the $new_ptrn to equal
'character varying (100)', I got the multiple
'(100)' again.
So, I need to escape the '(', ')' better.
I'm still working on the RegEx stuff.
Thanks again!
-X
>>-----Original Message-----
>>From: John W. Krahn [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, July 08, 2003 4:52 PM
>>To: [EMAIL PROTECTED]
>>Subject: Re: problems replacing a pattern in file
>>
>>
>>Shaunn Johnson wrote:
>>>
>>> >>From: John W. Krahn [mailto:[EMAIL PROTECTED]
>>> >>
>>> >>Shaunn Johnson wrote:
>>> >>>
>>> >>> # create a loop to search for one instance of
>>> >>> # my password and change it to something else
>>> >>> # one day, i'll get smart and ask for a paramater, too
>>> >>>
>>> >>> for my $file(@list) {
>>> >>> open (FILE, $file) or die "can nae open this file: $!";
>>> >>>
>>> >>> #local $^I=".bak"; # to keep a backup of the files
>>> >>> local $^I=""; # to keep a backup of the files
>>> >>> # set to "" if i don't want backups
>>> >>> local @ARGV = @list; # the files to work on
>>> >>> while (<>) {
>>> >>> s!$pattern!$new_ptrn!g ;
>>> >>> print;
>>> >>> } # end while loop
>>> >>> close (FILE);
>>> >>> } #end of for loop
>>>
>>> Thanks for the reply:
>>>
>>> Are you sure that the problem isn't in the 'for' loop?
>>> It seems odd that I have eight files in the directory
>>> and eight counts of the (100) at the end of the lines.
>>>
>>> I am going to try something with the for loop and see
>>> if that gets me anywhere.
>>
>>Yes, you definately have a problem in the for loop. You are looping
>>through the file names in @list and then assigning that
>>complete list to
>>@ARGV for every file in list. Just assign the current file name to
>>@ARGV or better assign the list to @ARGV and let perl handle the file
>>opening and closing for you.
>>
>>
>>#local $^I = '.bak'; # to keep a backup of the files
>>local $^I = ''; # to keep a backup of the files
>> # set to "" if i don't want backups
>>local @ARGV = @list; # the files to work on
>>while ( <> ) {
>> s!$pattern!$new_ptrn!g ;
>> print;
>> }
>>
>>
>>John
>>--
>>use Perl;
>>program
>>fulfillment
>>
>>--
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>