in reply to deleting a list of files

Your grep should have !/^\.\.?$/ rather than !/\.\.?/. Your pattern will match any filename with a dot in it, which results in any file with a dot in its name will not be in @imss, which is probably why your files aren't being deleted. /^\.\.?$/ will match only '.' and '..' which I believe is what you are trying to do.

Replies are listed 'Best First'.
Re: Re: deleting a list of files
by merlyn (Sage) on Mar 25, 2001 at 19:15 UTC

      I'm curious: I've always just used /^\.\.$/, assuming that it would be sufficient. Are you recommending /\A\.\.\z/ as a defensive programming practice or are there specific situations you've run into where you needed to do this?

        I'm just saying that it won't correctly categorize either dot-newline or dot-dot-newline, and that's a potential security hole if someone understands that, or at least an annoyance if it doesn't.

        See.. .if I wanted to remove all the files in a directory so I could rmdir it, and I used that regex to skip over dot and dot-dot, I'd also be skipping over dot-newline and dot-dot-newline, and then my rmdir would be failing mysteriously. A potential security hole if the presence of that directory permits me access to something I shouldn't have.

        -- Randal L. Schwartz, Perl hacker