Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Advice/help with beginner script (file sorting, execute command line command)

by Laurent_R (Canon)
on May 21, 2014 at 21:25 UTC ( #1087028=note: print w/replies, xml ) Need Help??

in reply to Advice/help with beginner script (file sorting, execute command line command)

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: 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.

Replies are listed 'Best First'.
Re^2: Advice/help with beginner script (file sorting, execute command line command)
by UserMane (Initiate) on May 21, 2014 at 23:44 UTC
    Thank you for the helpful links. You are correct that reading tutorials and examples is a good place to start. This is work related and unfortunately it may take some time to get around to. I will try to post an example of what I've written when I come up with something. I will admit I was looking for a bit of a shortcut; in my search I've come across 3 line examples that will do something similar in Bash and PowerShell, and an expert could probably do this in a few minutes. Hopefully I'll get there.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1087028]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2018-02-22 05:22 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (288 votes). Check out past polls.