What's stopping you? The answer to your question lies in you trying to understand the code you have. You already have the file name in your $file variable. You can get information on files using the -X family of operators, but you should know that already since your code contains -f. stat might also be helpful.
I find it odd that you say it's working now, as I took your posted code, attempted to run it, and obtained the errors:
String found where operator expected at fluff.pl line 35, near ") "Dir
+ectories: $directory_count |""
(Missing operator before "Directories: $directory_count |"?)
print (...) interpreted as function at fluff.pl line 36.
String found where operator expected at fluff.pl line 36, near ") "Fil
+es: $file_count\n""
(Missing operator before "Files: $file_count\n"?)
syntax error at fluff.pl line 35, near "$OUTF) "
syntax error at fluff.pl line 36, near ") "Files: $file_count\n""
Execution of fluff.pl aborted due to compilation errors.
I can also spot a number of other issues that would be caught by strict and warnings, as you claim to have implemented Re^2: Perl Script to count files and directories is not working.. As an internet programming forum, PerlMonks is ridiculously respectful and helpful to the neophyte. We do not have patience for people who show no effort. I highly recommend you read How To Ask Questions The Smart Way and meditate on it before posting again. |