Brian Volk am Mittwoch, 3. August 2005 17.50: > Hi All~ > > my program below is not returning any errors but nothing is happening to > the .txt files like I hoped. Can someone pls take a look and let me know > what I'm doing wrong. > > ----- Thank you! ---- > > # If there is a .pdf file and a matching .txt file, open the .txt file and > s % http://.* % "$link" % > > #!/usr/bin/perl > > use strict; > use warnings; > use File::Basename; > > my $pdf_dir = "j:/flash_host/ecomm/descriptions/product/MSDS"; > opendir(PDFDIR, $pdf_dir) or die "Can't open the $pdf_dir: $!\n"; > > # read file/directory names in that directory into @htmls > > my @pdfs = readdir(PDFDIR) or die "Unable to read current dir:$!\n"; > > closedir(PDFDIR); > > my $text_dir = "c:/brian/descriptions/product/small"; > opendir (TEXTDIR, $text_dir) or die "Can't open $text_dir: $!"; > > # read all the .txt files and load @ARGV for <> operator > > @ARGV = map { "$text_dir/$_" } grep { !/^\./ } readdir TEXTDIR; > > my %PDFDIR_LIST; > > $PDFDIR_LIST{$_}=1 for @pdfs; > > foreach my $text_file (<>) {
This tries to open and read the files whose names are specified in @ARGV: $ perl local @ARGV=(qw /a b c/); while (<>) {print}; Can't open a: No such file or directory at - line 2. Can't open b: No such file or directory at - line 2. Can't open c: No such file or directory at - line 2. > > my ($basename, $suffix) = fileparse($text_file,'.txt'); > my $link = "descriptions/product/small/$basename.pdf"; > > if( $PDFDIR_LIST{"$basename.pdf"} ){ > open FH, $text_file or die "can't open $text_file: $!"; > s% http://.* % $link %; > next;} > > } > close (FH); > closedir (TEXTDIR); > > __END__ hth, joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>