in reply to Re: How to find the path
in thread How to find the path

this is i tried.

my @xmlfile = File::Find::Rule->file()
->name( '*.xml')
->in( "$serpath" );

Replies are listed 'Best First'.
Re^3: How to find the path
by Anonymous Monk on Jun 08, 2009 at 07:02 UTC
    If
    my $serpath="D:\\eproof\\htdocs\\*\\work";
    use
    my @xmlfile = File::Find::Rule->file() ->name( '*.xml') ->in( glob $serpath );
    Here is a self-contained example (you need write permission in current directory)
    #!/usr/bin/perl -- use strict; use warnings; use Shell::Command qw( rm_rf touch mkpath ); use File::Find::Rule; use File::Spec::Functions; my $serpath = './temptest1'; # no trailing slash my $work = 'work'; my $time = int rand 20; mkpath( catfile( $serpath, $time, $work ) ); touch( map { catfile( $serpath, $time, $work, "$_.xml" ) } 1 .. 2 ); #touch(catfile( $serpath, $time, $work, "$_.xml" )) for 1 .. 2; { my @dirs = File::Find::Rule->directory->name($work)->in($serpath); print "dir $_\n" for @dirs; my @xmlfile = File::Find::Rule->file->name('*.xml')->in(@dirs); print "file $_\n" for @xmlfile; } print "wow $_\n" for File::Find::Rule->file->name('*.xml') ->in( glob catfile( $serpath, '*', $work ) ); mkpath("$serpath/$time/$work"); rm_rf('temptest1'); __END__ C:\>perl file.find.rule.pl dir temptest1/3/work file temptest1/3/work/1.xml file temptest1/3/work/2.xml wow temptest1\3\work/1.xml wow temptest1\3\work/2.xml C:\>perl file.find.rule.pl dir temptest1/15/work file temptest1/15/work/1.xml file temptest1/15/work/2.xml wow temptest1\15\work/1.xml wow temptest1\15\work/2.xml