Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Illegal seek from Find::File

by infoninja (Friar)
on Jun 02, 2000 at 00:30 UTC ( [id://15897]=perlquestion: print w/replies, xml ) Need Help??

infoninja has asked for the wisdom of the Perl Monks concerning the following question:

If I run the following code:
#!/usr/bin/perl -w use strict; use File::Find; my $username = 'testuser'; sub htaccess_test { if ($_ eq '.htaccess') { print "$_\n"; } } find(\&htaccess_test, "/home/$username/public_html/") or print "$!\n";
it prints ".htaccess" for each instance that it finds in the specified tree, and then prints "Illegal seek" - any idea what's causing the illegal seek and how to prevent it ?

Replies are listed 'Best First'.
Re: Illegal seek from Find::File
by btrott (Parson) on Jun 02, 2000 at 00:52 UTC
    I don't think find returns anything, which would cause the "print ..." bit of your condition to be executed. So your find is actually running successfully. There's no need to check for an error.

    Were you expecting find to return something?

    As for the "Illegal seek"--running the code through the debugger, it seems that $! gets set to "Illegal seek" after the call to Cwd::cwd(). And in Cwd::cwd (aliased to Cwd::_backtick_pwd), it gets set after running this line:

    chop($cwd = `pwd`);
    You can actually take out the chop, and still get the error:
    print "Before: ", $!, "\n"; my $cwd = `pwd`; print "After: ", $!, "\n";
    gives
    Before: After: Illegal seek
    And in fact, I get this w/ any backtick call:
    print "Before: ", $!, "\n"; my $cwd = `date`; print "After: ", $!, "\n";
    gives the same output. So it doesn't look like this is anything to worry about.
      I was originally hoping that it would, but after reading your reply, I think I've got a better way to handle the return.
      Out of curiosity, any idea what's causing the "illegal seek"?
        infoninja said:
        Out of curiosity, any idea what's causing the "illegal seek"?
        Nothing. That's an "expected error" that is unrelated to your operation, and has already been dealt with.

        Moral: Do not use $! on calls that are not immediately "system" calls.

        -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://15897]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found