Newbie Trying to learn perl

Discussion in 'Perl' started by Nathan M., May 4, 2004.

  1. Nathan M.

    Nathan M. Guest

    I needed some help trying to figure out how to write a small perl
    script in a Sun Solaris environment that can recursivly search through
    a directory structure and get file information such as owner, size,
    last modified date, permissions, things like that. I have tried to
    use a File::Find but because I am very new at this I don't know where
    to go from there. Thanks for any help.
     
    Nathan M., May 4, 2004
    #1
    1. Advertising

  2. Nathan M.

    Joe Smith Guest

    Nathan M. wrote:

    > I needed some help trying to figure out how to write a small perl
    > script in a Sun Solaris environment that can recursivly search through
    > a directory structure and get file information such as owner, size,
    > last modified date, permissions, things like that. I have tried to
    > use a File::Find but because I am very new at this I don't know where
    > to go from there. Thanks for any help.


    Are you aware that there is a perl utility called `find2perl`?
    You give it the same command line arguments as you would to `find`
    and it produces a perl program that outputs the same results.

    solaris% find /tmp /var/tmp -ls
    solaris% find2perl /tmp /var/tmp -ls >myprog.pl
    solaris% perl myprog.pl

    The relevant parts are:

    # Traverse desired filesystems
    File::Find::find({wanted => \&wanted}, '/tmp', '/var/tmp');
    exit;

    sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid);
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    ls;
    }

    sub ls () {
    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
    $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
    ...
    }


    -Joe
     
    Joe Smith, May 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike
    Replies:
    1
    Views:
    2,168
  2. Jack
    Replies:
    1
    Views:
    382
    IchBin
    May 19, 2006
  3. Porky Pig Jr
    Replies:
    3
    Views:
    1,077
    Fuzzyman
    May 12, 2004
  4. CoreyWhite
    Replies:
    1
    Views:
    675
    JohnQ
    Mar 31, 2007
  5. Alexander
    Replies:
    20
    Views:
    1,072
    BGB / cr88192
    Sep 11, 2010
Loading...

Share This Page