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]