I'm not really having /bad/ speed, it's just that using lstat 
within a C loop tests (and tastes) much better.

I've attatched the sub with the loop I want to inline. I realize that
by doing the lstat calls inside C and evaluating the results in PERL
that I will then be doing two loops. My testing initially shows this to
be well worth it.

On 06/12, Ryan Sadler rearranged the electrons to read:
> 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.

The cookbook and perlguts are useful to those more comfortable with C
than I am yet. I am trying, but also asking for help.

> 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 defeats the purpose of the inlining. I would love if the list_dir C
inline sub returned an arry of scalars which would be something like
<st_dev>/<st_ino>/<mode>/<size>/<mtime>/<filename>

And maybe some help on bitmasking to check what type of file the thing
is and whether it's readable/writable.

> 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.

There really aren't speed issues. I just want to further optimize my
code.

--
Hob Goblin
[EMAIL PROTECTED]

"Did you sleep well?"  "No, I made a couple of mistakes."
                                                -- Stephen Wright

lookat.pl

Reply via email to