"Perlwannabe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > <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?
that's not the problem. in fact, you expect to see this in Windos. they are just CRLF. tell us a few things: * where's listitems.txt? (full path please) * where's testscript.pl? (full path please) * where are you executing testscript.pl? (full path please) * you are trying to delete files inside c:/testdir/ correct? as you might have notice by now, the script is very simple and there isn't a lot of places where it can go wrong. the location of those files are critical to the success your script. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]