Ryan Frantz wrote: > >>Randal L. Schwartz wrote: >> >>>>>>>>"Rob" == Rob Dixon <[EMAIL PROTECTED]> writes: >>> >>> Rob> my @new = grep /[^.]/, readdir DIR; >>> >>> This is still the wrong regex. While it's narrow enough for >>> windows, it will *break* on Unix. No reason not to do the right thing here: >>> >>> grep { $_ ne "." and $_ ne ".." } readdir DIR; >>> >>> Rob, I'm surprised you still posted this even after our private >>> email exchange. You were *told* in email that this regex is broken. >>> Therefore, I will warn others to please discount Rob's postings in >>> the future, >> >>>[...] >> >> Not quite. Rob's program works for rational input data. I'm on *nux, >> and I consider a filename of only periods to be invalid. All that's needed >> is a comment in the code that warns people that files consisting of >> only periods, including '...', are excluded. > > The regex that Rob put forth does not match only files consisting > entirely of periods, it matches any file that _starts_ with a period. > On a *nix system, a file such as '.bash_profile' would be matched. > Randal is correct.
No it doesn't. I don't see why there's so much confusion about this regex. Randal wrote: :: But certainly not for correctness! It's easy to look pretty if you don't :: care about the right answer. Your regex rejects *any* filename that contains :: *any* dot. On a windows system, that'd be just about any file. :) and that's wrong too. The character class [^.] matches any character that isn't a dot, so the grep will passs through all files that contain any non-dot character. >>Your attack on Rob is uncalled-for. > > I don't believe that Mr. Schwartz attacked the OP; he merely stated that > others should check Rob's responses for accuracy. In fact, given that > this is a beginner's list, that probably holds true in other instances. I wasn't the OP, but I assume you mean me. Randal didn't just say my responses should be checked for accuracy, he said (above): :: I will warn others to please discount Rob's postings in the future, which is much more inflammatory. Randal certainly knows his Perl, but he was simply wrong in this case and put his point over less than politely. I am sure the thread would never have taken this turn if the only mistake he saw in my post was that filenames with just dots would be rejected. Indeed, that post was in reply to a Windows user who could not have had such files anyway. Instead Randal saw a mistake in the regex that wasn't there and went ahead and rubbished the whole post without grounds. It is only since I pointed out his mistakes that he adopted the alternative 'three-dot filename' in what seems to be a weak attempt to prove that at least something was wrong with my post - even though he didn't see it in the first place. Yes, there is a hole in my code, but I don't consider it a huge yawning one that deserves a court martial. I would go as far as to say that it remains a useful construct - certainly on Windows, and usually on *nix where files with such unprincipled names just don't exist. By all means disagree with me and don't use it, but it is there if you want it. > And the fact the Randal has written a little on the subject of Perl, inclines > me to trust his judgement. Just because Randal has publications to his name doesn't make him any less prone to mistakes, as we have seen in his original post on this thread. That he is more aggressive and vociferous than most don't to me make him more worth reading. To me he is just a regular guy who is sharp at Perl but needs to control his language a bit better. Again, whether you agree with me is up to you. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>