in reply to Deleting Directories from a path by reading information from Database columns
Are you looking for a way to delete the directories using the Id directory using the "number" column and base directory (c:\Documents and Settings\user\Files)?
If so, then check out remove_tree in the File::Path module.
remove_tree( $dir1, $dir2, ...., \%opts )
The remove_tree function deletes the given directories and any files and subdirectories they might contain, much like the Unix command rm -r or del /s on Windows.
use strict; use warnings; use DBI; use File::Path; my $base_directory = 'c:/Documents and Settings/user/Files'; my $db = DBI->connect( "dbi:Oracle:*****", "*****", "*** +***" ) || die( $DBI::errstr . "\n" ); $db->{AutoCommit} = 0; $db->{RaiseError} = 1; $db->{ora_check_sql} = 0; $db->{RowCacheSize} = 16; my $SEL = "SELECT number,id,status FROM info where statu +s in ('I,D')"; my $sth = $db->prepare($SEL); $sth->execute(); while ( my $row = $sth->fetchrow_hashref() ) { my $folder = $row->{number}; # folder my $subfolder = $row->{Id}; # subfolder my $directory = "$base_directory/$folder/$subfolder"; if (-d $directory) { if (remove_tree($directory)) { print "DIRECTORY HAS BEEN DELETED:: [$directory]\n"; } else { print "[Error] UNABLE TO DELETE DIRECTORY: [$directory]\n"; } } } ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Deleting Directories from a path by reading information from Database columns
by Anonymous Monk on Dec 29, 2010 at 00:01 UTC | |
by Anonymous Monk on Dec 29, 2010 at 00:25 UTC | |
by Anonymous Monk on Dec 29, 2010 at 00:46 UTC |