This code seem to work fine. open(FH,"listitems.txt") || die $!; unlink map{chomp; glob "c:/testdir/*$_*.*" } <FH> or die $!; close(FH);
I created files with names that include texts in the listitems.txt file and they were all deleted except those that doesn't match. ----- Original Message ----- From: "perlwannabe" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, August 08, 2003 7:16 PM Subject: Re: Still need unlink help!! God help me. > <SNIP, SNIP> > >> > >> The directory c:/testdir/ contains many files, but I want to delete > >> the files with any *item###*.* from the directory. So if the > >> directory has 3000 files I want to delete every file that has item997 > >> in it. > >> > > > > glob returns the relative path of the files so if you are in a > > different > > directory (other than c:/testdir) executing the script, it will not > > find the files. try fully qualify the path: > > > > #!/usr/bin/perl -w > > use strict; > > > > open(FH,"listitems.txt") || die $!; > > unlink map{chomp; glob "c:/testdir/*$_*.*" } <FH> or die $!; > > close(FH); > > > > __END__ > > > > or: > > > > [x]$ perl -lne 'unlink glob "c:/testdir/*$_*.*" or die $!' > > listitems.txt > > This suggestion returned the error: > > Died at testscript.pl line 4, <FH> line 15. > > I tried both the suggested methods without success. But, I mightuv found a > problem. I tried all of these methods with no success and looked at the > input file "listitems.txt" and found something interesting when using a > hexeditor. Each line ends with 0D0A, so in a hex editor the previous file > looks like: > > item9970D0Aitem9960D0Aitem9990D0Aitem9830D0A > > but when I look at the file with notepad it looks like: > > item997 > item996 > item999 > item983 > > Could this be the culprit? > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 7/24/2003 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]