Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem parsing the directory

Newbie
 
Join Date: Feb 2007
Posts: 2
#1: Feb 8 '07
Hi,

I am using perl in windows platform. I have a directory structure \Dir\Data\tran\Archive\TDB\Log. There are files in the TDB directory with .dat extension. I need to parse the TDB directory inorder to identify the .dat files individually. I have the logic as follows:

# file path
$input = "\\Dir\\Data\\tran\\".$ARGV[0];
$archive = "\\Dir\\Data\\tran\\Archive\\".$ARGV[0];
$archLog = $archive."\\Log";

die "Can not open archive directory"
unless (opendir ARC, $archive);

mkdir($archLog, 0777)
unless (opendir ARCLOG, $archLog);

# moving from input to archive
$mvString = "move ".$input."\\*.dat ".$archive."\\";

#
while ($fn = readdir ARC)
{
if (substr($fn,0,1) ne "." and substr($fn,0,3) ne "Log")
{
$fn =~ /.dat/ ? $fn =~ /:|MemberTranArchive/ ? ($dummy = $fn) : &mvFile($archive,$fn) : ($dummy = $fn);
}
}

closedir ARCDIR


With this logic in place, I get . and .. (current and parent directory) and finally it jumps to Log directory. The logic never looks for the files in the TDB directory.

How to make the logic work to parse the directory TDB?

The same logic works fine on unix platform. I am trying to make it work on windows.

Am I missing something here?

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Feb 9 '07

re: Problem parsing the directory


what are ARCLOG and ARCDIR used for? What does this line do?

Expand|Select|Wrap|Line Numbers
  1. $fn =~ /.dat/ ? $fn =~ /:|MemberTranArchive/ ? ($dummy = $fn) : &mvFile($archive,$fn) : ($dummy = $fn);
docsnyder's Avatar
Member
 
Join Date: Dec 2006
Location: Darmstadt
Posts: 88
#3: Feb 9 '07

re: Problem parsing the directory


@codemaster

Try this:
Expand|Select|Wrap|Line Numbers
  1. @files = glob("$yourLogDir/*.dat");
Greetz, Doc
Reply