I am new to perl scripting and wrote a perl script to read the directories and files and count the no of files in each directory and generate a log file. The problem is it is not printing anything to the log file. I am copying the script below.
!/usr/local/bin/perl $dir= 'c:\My Projects\Perl Scripts\New Folder' ; $directory_count = 0; $file_count=0; $outfile = 'log.txt'; open OUTF, "> $outfile" or die print " can't create logfile; $!"; for $dir ( @dirs ) { opendir( DIR, "$dir" ) ; @files = readdir( DIR ) ; foreach $file ( @files ) { if ( -f "$dir/$file") { $directory_count++; } else { $file_count++; } } { print "Directories: $directory_count\n"; print "Files: $file_count\n"; } closedir( $dir ) ; } close OUTF ; exit 0;
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |