in reply to How to find the path

Where is your code?

Replies are listed 'Best First'.
Re^2: How to find the path
by amexmythili (Novice) on Jun 08, 2009 at 03:47 UTC
    this is i tried.

    my @xmlfile = File::Find::Rule->file()
    ->name( '*.xml')>br> ->in( "$serpath" );
      in only works for directory names, not wildcards. I suggest you try finding all directories in D:\\eproof\\htdocs first, then searching in those.
Re^2: How to find the path
by amexmythili (Novice) on Jun 08, 2009 at 03:48 UTC
    this is i tried.

    my @xmlfile = File::Find::Rule->file()
    ->name( '*.xml')
    ->in( "$serpath" );
      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