You guys are great!

-----Original Message-----
From: Wagner-David [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 27, 2001 4:46 PM
To: [EMAIL PROTECTED]
Subject: RE: Read text files only into a hash


        I made the change as 
        $dir_file = "$dir/$file";

      next if ( -d $dir_file );     # if directory then next
        next unless -T "$dir_file";     # if not a text or what exhibits
text file next

Ran it it got only text files and no directories.

Wags ;)

-----Original Message-----
From: Shepard, Gregory R [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 27, 2001 14:13
To: [EMAIL PROTECTED]
Subject: RE: Read text files only into a hash


It still appears that the -T is also reading the directories in to the hash.
the statement below looks logical. Is there a test to specifically exclude
directories? 


while ($file = readdir DIR) 
        {
        next unless -T "$dir/$file" || ~/^\./;

        $dir_file = "$dir/$file" if -T "$dir/$file";
                
        @filespecs = stat("$dir_file");                  
        $filespecs = $filespecs[9].$time_num;   
        $time_table{"$filespecs"} = "$file";
        $time_num++;
        }


-----Original Message-----
From: Mooney Christophe-CMOONEY1 [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 27, 2001 3:56 PM
To: Mooney Christophe-CMOONEY1; [EMAIL PROTECTED]
Subject: RE: Read text files only into a hash


Sorry -- let me try that again ...

Why don't you change your next statement to:
next unless -T "$dir/$file" || /^\./;

-----Original Message-----
From: Shepard, Gregory R [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 27, 2001 3:47 PM
To: [EMAIL PROTECTED]
Subject: Read text files only into a hash






All, 
I am trying to read only text files (using the -T test) from a directory
into a hash, and not directories themselves. How do I prevent it from it
reading in directories? This sounds like a basic question and know there is
probably an easy answer... but I can't think of it. Thanks.


@ARGV=$dir;
$directory=shift || '.';                
opendir DIR, $directory or die "Can't open directory $directory: $!\n";
my $time_num=10000;                                                     
my $hash_num=0;

while ($file = readdir DIR) 
        {
        next unless -T "$dir/$file" || ~/^\./;

        $dir_file = "$dir/$file" if -T "$dir/$file";
                
        @filespecs = stat("$dir_file");                  
        $filespecs = $filespecs[9].$time_num;   
        $time_table{"$filespecs"} = "$file";
        $time_num++;
        }
close DIR;       

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

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

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

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

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

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

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

Reply via email to