Hi to all,
I have written a Perl script that is invoked from the File menu in team site. The perl script when invoked, parses all the DCR's (in a pre-specified directory) and returns only the ones that have a particular hidden field value. This is done but the directory is hard coded into the script.
Now I want to make this script generic. No matter in which directory i am, on executing the script, it should scan all the DCR's that come under that tree. That is, it should find all the Data Type folders under the current directory (at any depth) and return a list of DCR's as in the earlier case, but now grouped by data types (as more than one are involved now).
Please let me know how can this be accomplished
Current Hard coded script:
sub navigate_dir
{
my $filecount;
my $filecounter = 2;
my $dcr_name;
my $source_path =" Here the path is specified "; # this path now needs to be made generic
#opening the directory containing the dcr's
opendir(TEMP, $source_path);
# adding all the DCR file names to an array
@FILES=grep(!/^\.\.?}$/, readdir TEMP);
#count of no. of DCR's
$filecount = @FILES;
closedir(TEMP);
#loop through all the DCR
while($filecounter<$filecount)
{
$dcr_name = $FILES[$filecounter]; # reading the DCR name from the array
$dcr_path=$source_path."\\$dcr_name"; # full file path of the DCR
# Invoke subroutine to parse the xml file (dcr)
process_data($dcr_path,$dcr_name);
$filecounter = $filecounter + 1; # increment the file counter
}
}
Thanks