Howdy: I know this should be pretty simple, but I must be missing something in my code. I want to do the following:
* get a list of files in a directory * open each file * search and replace the old pattern to a new pattern (should only be one occurrence) * close file * close dir * do next one until the end of list But nothing is happening (that I can see). What am I doing wrong? ### perl code ### #!/usr/bin/perl -w use diagnostics; # # this is a script to look for and change the password # for the sql scripts that i have lying around for production # i'm at the point where i need to be a bit more lazy. # # create a few variables my $sqldir='/samba/sql_scpt'; my $pattern="jun12"; my $newpattern="jul12"; opendir (DIR, $sqldir) or die "can nae access B drive mounted directory: $!"; # create and array and read in a list of files but NOT # root and current dir my @list = grep {$_ ne 'temp' and $_ ne 'devel' and $_ ne '.' and $_ ne '..'} readdir(DIR); # 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 the file: $!";; while (<FILE>) { s!$pattern!newpattern!g ; } # end while loop } #end of for loop close (FILE); close (DIR); __END__ ### end of perl code ### Suggestions? Thanks! -X