On 8/4/05, Brian Volk <[EMAIL PROTECTED]> wrote: > for now it's back to the drawing board and waiting for that light in my head > to go off! :~)
Brian, I took the last script you posted and re wrote it the way I would have gone about it. It doesn't use in-place editing, or @ARGV, because I don't quite grasp how to make that work in this situation. Anyway, see if it helps... I apologize if there are errors, I couldn't quickly think of a way to test it. #!/usr/bin/perl use strict; use warnings; use File::Basename; use File::Copy; my $pdf_dir = "j:/flash_host/ecomm/descriptions/product/MSDS"; # read file/directory names in that directory into @pdfs opendir PDFDIR, $pdf_dir or die "Can't opendir $pdf_dir: $!\n"; my @pdfs = readdir(PDFDIR); closedir PDFDIR; my $text_dir = "c:/brian/descriptions/product/small"; opendir TEXTDIR, $text_dir or die "Can't opendir $text_dir: $!"; my @txts = map { "$text_dir/$_" } grep { !/^\./ } readdir TEXTDIR; closedir TEXTDIR; my %PDFDIR_LIST; $PDFDIR_LIST{$_}=1 for @pdfs; foreach my $text_file (@txts) { my ($basename, $suffix) = fileparse($text_file,'.txt'); my $link = "descriptions/product/small/$basename.pdf"; if( $PDFDIR_LIST{"$basename.pdf"} ) { my $out_file = "$textfile.new"; open INPUT, "< $text_file" or die "can't open $text_file: $!"; open OUTPUT, "> $out_file" or die "can't open $out_file: $!"; while (<INPUT>) { s% http://.* % $link %; # are you sure you don't need the g option? print OUTPUT; } close INPUT; close OUTPUT; move( $text_file, "$text_file.bak" ); move( $out_file, $text_file ); } } __END__ -- Adam Wuellner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>