There are some excellent examples in the C-Cookbook.pod in the Inline
distro that do just what you want to do. Try playing with these
examples to get a feel for inlining C. You should also peruse the
perlguts page to understand the C/Perl interface.
You'll probably want to do something like this
foreach $filename (list_dir("/")) {
lstat $filename;
print "$filename: ";
print "Readable " if -r _;
print "Writable " if -w _;
print "Executable " if -x _;
print "Setuid " if -u _;
print "Setgid " if -g _;
print "Sticky " if -k _;
print "Text " if -T _;
print "Binary " if -B _;
print "\n";
}
This uses the perl lstat which may be a very efficent one. Try replacing
it with your own lstat and see if there is any noticable difference. I
wonder if the speed issues that you're having are just related to perl and
loading shared libraries.
Ryan
On Tue, 12 Jun 2001, Shawn Leas wrote:
> Ok, thanks! On to another question: How might I also return the stat
> data from the C code, and also be able to tell if the thing is a file,
> dir, fifo, char, block, etc etc from withing the perl? I figure it
> should return all the info in a concatenated string with the filename at
> the end.
>
> PLEASE excuse my lame questions... I'm sooo used to the sybolic nature
> of PERL that I never had to learn to do it in C. Now I'm a cripple. I'm
> trudging through some C tutorials, but they've not helped so far.
>
> On 06/12, Neil Watkiss rearranged the electrons to read:
> > On Tue, 12 Jun 2001, Shawn wrote:
> >
> > > Anyone know why the attatched script produces this error for every time
> > > it prints a line?
> >
> > Two comments (and a fix):
> >
> > In general, you never want to use 'map' unless you care about the return
> > value. You don't in this case, so you can use a for loop instead.
> >
> > Why is it a hash? It takes a bit of a close look to figure it out:
>
> --
> Hob Goblin
> [EMAIL PROTECTED]
>
> While I was gone, somebody rearranged on the furniture in my
> bedroom. They put it in _exactly_ the same place it was.
> When I told my roommate, he said: Do I know you?
> -- Stephen Wright
>