Can anyone help me make this script recursive? It's defeating my limited scripting ability so far.
I'm trying to get a directory listing out of an informix database (note, this is not an actual file structure so I can't just glob the files or do a 'dir' etc).
The following code does give me what I want for the top level directory:
This nicely outputs the contents of the top level folder 'databases~4':
However, what I need to do is where an entry is of type 'dir', such as DB_UTILITIES or CLIENT_DATA_SETUP or INITIAL_SETUP or MIGRATION above, I need to list the contents of that dir (and the contents of any dir that might be within them etc).
I need to make the above code recursive where $hash{$topdir}{$instance} = dir.
Can anyone assist with some pseudo or actual code to do this?
I'm trying to get a directory listing out of an informix database (note, this is not an actual file structure so I can't just glob the files or do a 'dir' etc).
The following code does give me what I want for the top level directory:
Code:
my ($name,$version,$instance,$type,%hash);
my $topdir='databases~4';
my @dircontent = `ccm query "is_child_of(\'$topdir:dir:1\', 'project~mine_2.5.2')" -u -f "%name---%version---%instance---%type"`;
foreach my $entry(@dircontent) {
chomp($entry);
($name,$version,$instance,$type)=split(/---/,$entry);
$hash{$topdir}{$instance}=$type;
if ($hash{$topdir}{$instance}=~m/dir/) {
print "$topdir\n\t$name,$version,$instance,$type\n";
} else {
print "\t$entry\n";
}
}
This nicely outputs the contents of the top level folder 'databases~4':
Code:
databases~4
DB_UTILITIES,5,1,dir
databases~4
CLIENT_DATA_SETUP,3,1,dir
databases~4
INITIAL_SETUP,1,1,dir
databases~4
MIGRATION,8,1,dir
wrapper.sql---11---1---SQL
However, what I need to do is where an entry is of type 'dir', such as DB_UTILITIES or CLIENT_DATA_SETUP or INITIAL_SETUP or MIGRATION above, I need to list the contents of that dir (and the contents of any dir that might be within them etc).
I need to make the above code recursive where $hash{$topdir}{$instance} = dir.
Can anyone assist with some pseudo or actual code to do this?