|No such thing as a small change|
Re: Advice/help with beginner script (file sorting, execute command line command)by Laurent_R (Prior)
|on May 21, 2014 at 21:25 UTC||Need Help??|
Well, what efforts have you made so far to try to solve these easy tasks?
Googling question 1 with the following reasonable search query "perl find current path", I get this page: https://www.google.fr/search?q=perl+find+current+path&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:fr:official&client=firefox-a&channel=sb&gfe_rd=cr&ei=qQ19U7bGI4GB8QfxroHoBA. The very first link (Cwd) will tell you about the Cwd module and getcwd (get current working directory) function that should help you solve question 1. Everything is explained, but if you need help to use this module, please show what you have attempted and tell us where it fails to give you what you want.
For question 2, you could possibly use the glob function to retrieve a list of directory entries, use the -d file test operator to find out if it is a directory, and to use the glob function again on that sub-directory to find the entries there. Then use the -s file test operator to find the size of each one. Finding the largest one should be easy relatively with a little bit of thinking.
OK, I have given you a few clues, I hope they will help you.
There are some modules that can do part of the work for you, but, in your case, I would probably recommend that you try to do it fully by yourself: you are obviously a beginner, you really need to write programs and think the whole process by yourself.
Once again, if you show some attempted code, many monks on this site, including myself, will be more than happy to help you. But we need to see your code, not only to verify that you are really trying (although this is part of the expectation), but more importantly because we need to see your code to know at which level you stand and what you need to learn or where you need guidance.
Sorry if my post is demanding things from you, but learning how to develop programs is a real challenge and requires some real work. We can help you solve specific problems and point to possible mistakes, we can't do the work for you. I could easily write the solution for you (it might take me less time than what I spent writing this detailed answer), but you would most probably not learn anything useful from it. I hope you are appreciating that I am trying to help you the best way.