View Single Post
  #1 (permalink)  
Old November 29th, 2010, 09:04 AM
John2112 John2112 is offline
Authorized User
Points: 94, Level: 1
Points: 94, Level: 1 Points: 94, Level: 1 Points: 94, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2007
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delete files without

Hello,

I am trying to delete files using Perl. The names of the files are in a text file called 'zsk_bestanden_4.txt'. The following program runs without problem but only produces the message that 'File could not be removed'. Indeed there are no files deleted.
What goes wrong?
Any help would be very much appreciated,

John

---------------------------------------------------------------------------------------------------------------------------------
use strict;
use warnings;
open (h_zsk_bestanden_4, "J:\\m_20_zsk\\m_02_bestanden\\zsk_bestanden_4.txt ") or die ("Unable to open zsk_bestanden_4.txt");
while (my $naam_meerling = <h_zsk_bestanden_4>)
{
chomp $naam_meerling;
my $bestand_1 = $naam_meerling;
unlink $bestand_1 or print "File could not be removed\n\n";
}
---------------------------------------------------------------------------------------------------------------------------------

zsk_bestanden contains:
--------------------------------------------------------------------------------------------
"J:\\m_23_zsk_bewaar_test\\test_000009_091243. xml"
"J:\\m_23_zsk_bewaar_test\\test_000010_091244. xml"
"J:\\m_23_zsk_bewaar_test\\test_000011_091245. xml"
"J:\\m_23_zsk_bewaar_test\\test_000012_091247. xml"
"J:\\m_23_zsk_bewaar_test\\test_000013_091249. xml"
"J:\\m_23_zsk_bewaar_test\\test_000014_091250. xml"
"J:\\m_23_zsk_bewaar_test\\test_000015_091251. xml"
"J:\\m_23_zsk_bewaar_test\\test_000029_091285. xml"
--------------------------------------------------------------------------------------------
Reply With Quote