Xref: utzoo news.software.b:3640 comp.sources.d:4409 Path: utzoo!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!samsung!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: news.software.b,comp.sources.d Subject: Re: C News "upact" in Perl 3.0 Message-ID: <256C5049.22@ateng.com> Date: 23 Nov 89 20:17:12 GMT References: <1989Nov22.233553.7585@NCoast.ORG> Followup-To: comp.sources.d Organization: A T Engineering, Tampa, FL Lines: 29 According to allbery@NCoast.ORG (Brandon S. Allbery): [From my Perl "upact"]: >| $low = ""; >>----------------^^ >| while ($f = readdir(dir)) { >| printf "%s\n", $f; >| next unless $f =~ /^[0-9]+$/; >| $low = $f if ($low eq "") || ($f < $low); >>------------------------------------^^^^^---------^^^^^^ >| } > >"eq" applies to strings; "<" applies to numbers. Best not to mix them; >as the Perl manual suggests, you can get unpleasant surprises. You _can_ get unpleasant surprises if you are not careful to use the correct comparison operator(s). However, in this case, you do not get unpleasant anything. The code is correct. Remember that the filenames come back as strings. Note the regular expression for acceptable filenames: all digits. Therefore the numeric test is valid. Further, note that the test ($low eq "") cannot succeed if any numeric files have been found. Anyone who doubts the correctness of this code is invited to E-Mail me for further explanation. -- You may redistribute this article only to those who may freely do likewise. Chip Salzenberg at A T Engineering; or "Did I ever tell you the Jim Gladding story about the binoculars?"