Hello,

It's my .* attempt I don't understand, seek help on. (seek/need ability to either all files in dir opened or pattern search the files in dir with only files that meet pattern opened)

(Win32 if that matters Win2k ActiveState 5.61 build 633) Next line is from when the script worked ok.

my @fils = grep /.txt/,readdir FILDIR; # works fine

# but instead of a hard coded search pattern, I wanted use of variable to add more flexibility. So I changed that above line into like next line

my @fils = grep /$filspec/,readdir FILDIR;


With .* assigned to $filspec the print line prints all files that are in that dir. But no files get opened. Instead, an error (see as per line 4 & 5 of next code as well as I took note that the file open line is line 18)


#!/perl/bin/perl -w

use strict;
my $pattern = '(?=.*\bmodule\b)';

#my $filspec = '.txt'; # works without error
my $filspec = '.*'; # brings error: permission denied at line 18

my $fildir = '/Programs/NOTETA~2/DOCUME~1';
opendir(FILDIR,$fildir)|| die "can't open $fildir $!";

my @fils = grep /$filspec/,readdir FILDIR;

closedir FILDIR;
print @fils;

foreach my $fil (@fils) {
    open(FIL,"$fildir/$fil")||die "can't $!"; # line 18
    while (<FIL>) {
        if (s/^H=($pattern)/$1/io) {
            print "$fil:$_" ;
        }
    }
    close FIL;
}
#end

--
Alan.


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to