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

I am writing something using File::Find and whenever my wanted() sub comes across a directory, I will determine the type of directory via a simple boolean:
if ($File::Find::parent eq 'data') { div_check $_; else { svc_check $_; }

But there's one small catch: there is no parentinfo available as far as I can see. Someone please prove me wrong!

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

Replies are listed 'Best First'.
Re: $File::Find::Parent desired
by jdporter (Paladin) on Nov 11, 2002 at 21:00 UTC
Re: $File::Find::Parent desired
by fruiture (Curate) on Nov 11, 2002 at 21:05 UTC

    No. I can't find $File::Find::parent in the File::Find manpage, too. What should "$parent" contain?

    Perhaps you're looking for File::Spec's splitdir() method and:

    my $parent = ( File::Spec->splitdir( $File::Find::dir ) )[-1]; if( $parent eq 'data' ){ # and so on ...

    HTH

    --
    http://fruiture.de
Re: $File::Find::Parent desired
by princepawn (Parson) on Nov 11, 2002 at 20:58 UTC
    This will work, pawn:
    File::Spec->rel2abs("..");
    since we are chdir'ed to the directory unless we configed otherwise.

    Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

      Good work, princepawn! Make sure you tell princepawn about it.