Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Please advice

by ashish_sun123 (Initiate)
on Aug 10, 2011 at 13:08 UTC ( [id://919653]=perlquestion: print w/replies, xml ) Need Help??

ashish_sun123 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Please advice
by kennethk (Abbot) on Aug 10, 2011 at 13:32 UTC

    This is not a code writing service - monks are generally very generous with their assistance, but we are here to assist you, not to do your work. Show us what you've tried, what didn't work, what you thought might work, etc.

    Also, please wrap input and output in <code> tags just like you would code - it will preserve white space formatting and prevent a couple of perlmonks shortcuts from kicking in.

    With regards to some of the specific questions you do ask, I would recommend checking out DateTime and File::Find.

Re: Please advice
by toolic (Bishop) on Aug 10, 2011 at 13:21 UTC
Re: Please advice
by thenaz (Beadle) on Aug 10, 2011 at 13:25 UTC

    You can get the arguments passed into your script via $ARGV[#] (e.g. $first = $ARGV[0];). Then use opendir() and readdir() to find all the files in each of the subdirectories. After that, it's just loops and print statements.

      I have written this much of code as of now.

      #!/usr/bin/perl use strict; use warnings; use POSIX (); print ("Enter the directory name and date as input arguments:"); chomp($which_directory=@ARGV[0]); chomp($which_date=@ARGV[1]); die("Nothing entered as directory path name\n" if ($which_directory eq + ""); die("Nothing enetered as update date\n" if ($which_date eq ""); opendir(DIR,$which_directory); my @dir = grep { !/^\.+$/ } readdir(DIR); foreach (@dir) { -->Here I need to get all sub directories and then do a cd in each + diectory }
        @ARGV is the array of command line arguments (see perlvar .. and they would not normally need to be chomped). If you want to prompt the user for arguments, you can use:
        print "Enter directory: "; chomp(my $dir = <STDIN>);
        Or you might try IO::Prompt. For searching subdirectories, you can use File::Find. You are automatically chdir'd to the directory of each file as it is 'found'.

        To do this manually, you will need a recursive subroutine. Instead, I would recommend using File::Find to iterate over your files.

        Good Day,
            Dean

        No need to chomp @ARGV, these are command-line arguments, they are not read from a file.
        To find if a file is a directory, you can use -d
        To find the date/time stamps on a file, use stat
Re: Please advice
by Anonymous Monk on Aug 10, 2011 at 13:20 UTC
    1. The first thing you need to do is open a text editor.
    2. Next, type in use strict; use warnings;
    3. Then write your perl script in there.

    Alternatively, you can fix the formatting of this post and then post it on jobs.perl.org, but be sure to include how much your are willing to pay.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Please advice
by perl.j (Pilgrim) on Aug 10, 2011 at 21:31 UTC
    Well, if you are asking us to make the code, your probably out of luck.
    --perl.j

      Monks, It is not my endeavour to get the code written from you. Definitely I need help. I beleive all of you will help me out! Kindly help me as of now for how to look for sub directories under a sub directory and then taking the time stamp of all files under that sub directory and then matching the timestamp Please guide me here!

        Did you read the documentation for File::Find yet? If so, what part of using File::Find can we clarify for you?


        Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://919653]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found