Hi! I would be VERY greatful for some help in doing something pretty
simple to all of you, but very hard for me at this point. I don't know
enough C to get the following done:

I don't know if this makes enough sense to grok, but here goes:

I want an inline C subroutine in my perl program to:
  1) opendir a directory if readable
  2) readdir the dir
  3) step through all the files and lstat them
  4) return the stat data of all the files (in whatever form is most
     convenient, probably SV)

So, basically, I pass the C sub a dirname, and it loops through and does
the lstating instead of doing it inside a PERL loop.

I guess the thing I really need help with is how to pass the various
"stat data" types back to the perl code. In reality, I don't even have
the C to do the looping through the dir at the moment,  but I figure I
can get that done easier than figuring out the stack var stuff. (I
would be really greatful for help with this too, if someone is willing)

Here is why... When I do this in perl, it goes something like:
  my @stats;
  opendir DIR, $directory;
  for (readdir DIR) {
    my $file = "$directory/$_";
    @stats = lstat($file);
  }
  closedir(DIR);

As you can see, on line 5 I do an lstat with each iteration of the PERL
loop. I really want to see if extra overhead of doing it from the
indirection of being inside a PERL loop costs me. I think it does
because some of the timings I've done for PERL loops vs ls -F on huge
dirs seem to suggest it.

--
Hob Goblin
[EMAIL PROTECTED]

I put my air conditioner in backwards.  It got cold outside.
The weatherman on TV was confused.  "It was supposed to be hot
today."
                                                -- Stephen Wright

Reply via email to