in reply to Re^3: log file in perl.
in thread log file in perl.

Hi,

I am sorry I did not mean to say its working for a wrong code. It was pasted from a wrong file which was not working earlier.This happened in a rush. I am pasting the code which is working fine now for me and I am also tweaking it as per the suggestions given stat and -x.

#!/usr/local/bin/perl use warnings; use strict; my $dir= 'c:\My documents\perl scripts\new folder'; my $directory_count=0; my $file_count=0; my $outfile = 'log.txt'; open my $OUTF, '>', $outfile or die "can't create logfile;$!"; opendir (DIR, $dir); my @files = readdir(DIR); foreach my $files(@files) { print {$OUTF}"$files |";} foreach my $file(@files) { if (-d "$dir/$file") { $directory_count++; } else { $file_count++; } } print { $OUTF} "$directory_count |"; #print { $OUTF} "$file_count \n";