in reply to Removing files with extentions of log and date-time.

Ok, I appreciate the help. As you have asked I am giving you the syntax for my date-time files. Filename.04Oct-12AM I have one other question. You are talking about the ^ (carrot) in the line
@files = grep(!/^\./, readdir(DIR));
right? If so, I removed it and it listed no files when ran, but when I went to that directory all the files where still there.

Replies are listed 'Best First'.
RE: Re: Removing files with extentions of log and date-time.
by chromatic (Archbishop) on Oct 08, 2000 at 21:09 UTC
    That line belongs as is. It's looking for all files that do not start with a literal period.

    Under Windows, the only files likely to do that are the directory aliases '.' and '..' -- and you don't really want to unlink those. Leave that line as is.

    One reason your regexes in the version you posted weren't working, besides the unnecessary caret, was because you didn't have the alternation moen provided. First, you'd skip anything that didn't end it '.log'. Unfortunately, that rule excludes anything that ends in '.txt' or your date format.

    In effect, the only thing left after that first rule would be '.log' files. Unfortunately, that wouldn't match the second rule, and no file would even make it to the third rule. So nothing was getting past those rules. (A file can't end in '.txt' and '.log' simultaneously.)

    I hope this helps.

(Dermot) RE: Re: Removing files with extentions of log and date-time.
by Dermot (Scribe) on Oct 08, 2000 at 21:14 UTC
    We have a slight misunderstanding. I was speaking of the carets in the three regular expressions a little further down. The regular expressions that you use to select which files to delete. They need to be written without the caret as the text that you want to match is not at the start of the line.

    In the grep statement you do need the caret. You need it because you want to exclude files that start with a fullstop (you probably call it a period). So, in the case of the grep you want to match:

    1. Start of line
    2. Followed by a fullstop
    3. Followed by anything at all

    This is different from later on when you want to match:

    1. Anything at all. It might be start of line, it might not.
    2. Followed by a fullstop. This might be just after the start of line. Then again, it might be a few characters further along the string being matched against.
    3. Followed by the letter l, then the letter o, then the letter g.

    Do you see the difference ?