how to search for a number of files in a directory using perl.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rameshramesh
    New Member
    • Jul 2007
    • 7

    how to search for a number of files in a directory using perl.

    how to search for a number of files in a directory using perl.
  • savanm
    New Member
    • Oct 2006
    • 85

    #2
    Hi Ram...

    This is the basic example

    use Cwd;
    $path=getcwd();
    opendir(DIR,$pa th) || die ("Path is invalid\n");
    @files=grep(/\./,readdir(DIR));
    $i=0;
    foreach $fil (@files)
    {
    print "$fil\n";
    $i++;

    }
    print "Total number of files $i";

    hope this will help you..

    nAvAs.M

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3

      Comment

      • rameshramesh
        New Member
        • Jul 2007
        • 7

        #4
        if i am supposed to search for some number of files and have to display,, what can i do..???

        Comment

        • numberwhun
          Recognized Expert Moderator Specialist
          • May 2007
          • 3467

          #5
          Originally posted by rameshramesh
          if i am supposed to search for some number of files and have to display,, what can i do..???
          Did you happen to see the example provided nicely, above, by "savanm"?

          Have you tried that example, or any other for that matter? If you are working on some code to do what you are asking and are having problems, then please post your code so we can help you with it. We aren't going to write it for you, but we will help you with your issues if we can.

          Regards,

          Jeff

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            Originally posted by rameshramesh
            if i am supposed to search for some number of files and have to display,, what can i do..???
            read the previous posts, look up the functions mentioned, (opendir, grep, readdir, freach, etc, etc, etc) try and understand them, write some code, test the code, then ask some questions about the code you wrote and where you are having problems. Simply repeating your question over is not going to inspire anyone to want to help you. You need to show some effort.

            If you had even looked at the book I posted a link for you, you would have come across chapter 6 page 213 which probably will help you.

            Comment

            • numberwhun
              Recognized Expert Moderator Specialist
              • May 2007
              • 3467

              #7
              Originally posted by KevinADC
              read the previous posts, look up the functions mentioned, (opendir, grep, readdir, freach, etc, etc, etc) try and understand them, write some code, test the code, then ask some questions about the code you wrote and where you are having problems. Simply repeating your question over is not going to inspire anyone to want to help you. You need to show some effort.

              If you had even looked at the book I posted a link for you, you would have come across chapter 6 page 213 which probably will help you.
              Oh, you mean you meant for that book to be looked at?!!?!!? Oh MAN!!! What the heck? LOL!

              Jeff

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #8
                Originally posted by numberwhun
                Oh, you mean you meant for that book to be looked at?!!?!!? Oh MAN!!! What the heck? LOL!

                Jeff

                hehehe... a "novel" idea, huh? ;)

                Comment

                • numberwhun
                  Recognized Expert Moderator Specialist
                  • May 2007
                  • 3467

                  #9
                  Originally posted by KevinADC
                  hehehe... a "novel" idea, huh? ;)
                  DOH!!! LOL!

                  Jeff

                  Comment

                  Working...