in reply to Re: log file in perl.
in thread log file in perl.
Thank you and its working now. If possible can I know how to tweak my script to get filenames, date and time in addition to counts.
#!/usr/local/bin/perl my $dir= ('c:\My Projects\Perl Scripts\New Folder') ; $directory_count = 0; $file_count=0; $outfile = 'log.txt'; open my $OUTF, "> $outfile" or die print " can't create logfile; $!"; opendir( DIR, "$dir" ) ; my @files = readdir( DIR ) ; foreach $file ( @files ) { if ( -f "$dir/$file") { $directory_count++; } else { $file_count++; } } print {$OUTF) "Directories: $directory_count |"; print ($OUTF) "Files: $file_count\n"; closedir( DIR ) ; } close OUTF ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: log file in perl.
by kennethk (Abbot) on Aug 27, 2010 at 21:00 UTC | |
by Anonymous Monk on Aug 28, 2010 at 00:38 UTC | |
|
Re^3: log file in perl.
by vek (Prior) on Aug 27, 2010 at 20:57 UTC |