I have tried following code, where I am assigning @ARGV[0] to $directory variable and then passing $directory variable to sub wanted as you can see in the following code. But it only accepts "C:\directoryname" as an argument. I want the code to handle all the cases such as "C:\", "C:\*", C:\direcoryname\*" etc as I showed in my original email. Also is there any way to handle multiple paths or pathlist provided on command line ?

Please help.

Thanks
find(\&wanted, $directory); sub wanted { if (-d $_) { $totaldirs++; return; } else { $totalfiles++; @Stats = stat($_); $size = $Stats[7]; $ATime = $Stats[8]; $ModTime = $Stats[9]; $CTime = $Stats[10]; if (!$Windows && $opt_o ) { $owner = $Stats[4]; $owner = "\\" . getpwuid($owner); if ($owner eq "\\") { $owner = ''; } } elsif ($hasWin32Perms && $opt_o) { $object = new Win32::Perms ( $_ ) || die; $owner = $object->Owner(); $object->Close(); } ################################################################## +################ ## Filter Checks # Owner if ($i_owners && ($i_owners ne $owner) && $opt_o) { return; } # File Size if ($i_filesizemax && $i_filesizemin) { if ($size > $i_filesizemax || $size < $i_filesizemin) { next; +} } # Included File Types if (@i_incfiletypes) { $match = 0; foreach my $ext (@i_incfiletypes) { $ext =~ s/^\.//; if ($_ =~ m/.$ext$/) { $match = 1; last; } } if (!$match) { return; } } # Excluded File Types if (@i_excfiletypes) { $match = 0; foreach my $ext (@i_excfiletypes) { $ext =~ s/^\.//; if ($_ =~ m/.$ext$/) { $match = 1; last; } } if ($match) { return; } } # Date Modified if ($i_datemodifiedstart && $i_datemodifiedend) { if ($ModTime < $i_datemodifiedstart || $ModTime > $i_datemodif +iedend) { next; } } # Date Created if ($i_datecreatedstart && $i_datecreatedend) { if ($CTime < $i_datecreatedstart || $CTime > $i_datecreatedend +) { next; } } # Date Accessed if ($i_dateaccessedstart && $i_dateaccessedend) { if ($ATime < $i_dateaccessedstart || $ATime > $i_dateaccessede +nd) { next; } } $filterfiles++; ################################################################## +################ $writer->startTag("File"); ## OWNER ### $writer->dataElement("FileOwner", $owner);All files in directoryna +me and its subdirectories. $dir = $File::Find::dir; #$dir =~ s!\/!!; $dir =~ s!/!\\!g; $dir =~ s!\\\\!\\!; $dir = $dir . "\\"; $dir =~ s!:\\\\!:\\!; $writer->dataElement("FilePath", $dir); $writer->dataElement("FileName", $_); ################################################################## +################ ## FILE ACCESSED ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( +$ATime); $year += 1900; $mon++; $mday = "0$mday" if $mday < 10; if ($hour > 12) { $hour = $hour - 12; $ampm = "PM"; } else { $hour = 12 if $hour == 0; $ampm ="AM"; } $min = "0$min" if $min < 10; $sec = "0$sec" if $sec < 10; #print "\t\t<FileAccessed>$mon/$mday/$year $hour:$min:$sec $ampm< +/FileAccessed>\n"; #$writer->dataElement("FileAccessed", "$mon/$mday/$year $hour:$min +:$sec $ampm"); $writer->dataElement("FileAccessed", "$mon/$mday/$year"); ################################################################## +################ ## FILE MODIFIED ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( +$ModTime); $year += 1900; $mon++; $mday = "0$mday" if $mday < 10; if ($hour > 12) { $hour = $hour - 12; $ampm = "PM"; } else { $hour = 12 if $hour == 0; $ampm ="AM"; } $min = "0$min" if $min < 10; $sec = "0$sec" if $sec < 10; #print FH "\t\t<FileModified>$mon/$mday/$year $hour:$min:$sec $amp +m</FileModified>\n"; #$writer->dataElement("FileModified", "$mon/$mday/$year $hour:$min +:$sec $ampm"); $writer->dataElement("FileModified", "$mon/$mday/$year"); ################################################################## +################ ## FILE CREATED ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( +$CTime); $year += 1900; $mon++; $mday = "0$mday" if $mday < 10; if ($hour > 12) { $hour = $hour - 12; $ampm = "PM"; } else { $hour = 12 if $hour == 0; $ampm ="AM"; } $min = "0$min" if $min < 10; $sec = "0$sec" if $sec < 10; #$writer->dataElement("FileCreated", "$mon/$mday/$year $hour:$min: +$sec $ampm"); $writer->dataElement("FileCreated", "$mon/$mday/$year"); ################################################################## +################ # Turn size into KB and round up to next integer divisible by 4 $size = ceil($size / 1024); while ($size % 4 != 0) { $size++; } $writer->dataElement("FileSize", $size); $writer->endTag(); } } $writer->endTag(); $writer->end(); $output->close(); ##################################################################### print "File Scan is complete.\n"; print ":::Statistics:::\nDirectories:\t$totaldirs\nFiles:\t$totalfiles +\nFiles that passed Filters:\t$filterfiles\n";

In reply to Re^2: To retrieve all files according to given path list by devlele
in thread To retrieve all files according to given path list by devlele

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.