in reply to special directory entries
A better regex would be /^\.\.?\z/ since it will deal with these odd filenames correctly.#!/usr/bin/perl -wT use strict; my @arr = (".", "..", ".\n", "..\n", "file.txt"); my @files = grep !/^\.\.?$/, @arr; print "'$_'\n" for @files; # <== only prints 'file.txt'
Update: Reworded the first sentence, since it was rather unclear.
-Blake
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: special directory entries
by Fastolfe (Vicar) on Dec 04, 2001 at 02:29 UTC | |
by blakem (Monsignor) on Dec 04, 2001 at 02:35 UTC |