[30547] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1790 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 12 16:09:44 2008

Date: Tue, 12 Aug 2008 13:09:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 12 Aug 2008     Volume: 11 Number: 1790

Today's topics:
    Re: double slash operator syntax question <hjp-usenet2@hjp.at>
    Re: double slash operator syntax question <hjp-usenet2@hjp.at>
    Re: FAQ 4.2 Why is int() broken? (David Combs)
    Re: FAQ 4.2 Why is int() broken? (David Combs)
    Re: FAQ 4.2 Why is int() broken? <hjp-usenet2@hjp.at>
    Re: FAQ 4.2 Why is int() broken? <hjp-usenet2@hjp.at>
    Re: FAQ 5.6 How do I make a temporary file name? <brian.d.foy@gmail.com>
    Re: How to check for filetype existence quickly xhoster@gmail.com
    Re: How to check for filetype existence quickly <hjp-usenet2@hjp.at>
    Re: OO Perl <hjp-usenet2@hjp.at>
    Re: Question about variable scope (David Combs)
    Re: Question in Perl Arrays (David Combs)
    Re: Question in Perl Arrays <ben@morrow.me.uk>
    Re: The Importance of Terminology's Quality (Robert Maas, http://tinyurl.com/uh3t)
    Re: what is the option '/gee' used for in the RE expres <ben@morrow.me.uk>
    Re: what is the option '/gee' used for in the RE expres <glex_no-spam@qwest-spam-no.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 12 Aug 2008 19:39:40 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: double slash operator syntax question
Message-Id: <slrnga3ims.hb1.hjp-usenet2@hrunkner.hjp.at>

On 2008-08-11 13:42, Justin C <justin.0805@purestblue.com> wrote:
> On 2008-08-11, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>> On 2008-08-11 08:33, Lars Eighner <usenet@larseighner.com> wrote:
>>> In our last episode, <slrng9vrnp.2gj.hjp-usenet2@hrunkner.hjp.at>, the
>>> lovely and talented Peter J. Holzer broadcast on comp.lang.perl.misc:
>>>> On 2008-08-11 03:55, Lars Eighner <usenet@larseighner.com> wrote:
>>>>> Michael Carman:
>>>>>> It's the defined-or operator that was added in Perl 5.10. It's like ||
>>>>>> but tests for definedness instead of truth.
>>>>>
>>>>> It's in 5.8.8 or my perl is lying.
>>>>>
>>>> I think your perl is lying. My perl 5.8.8 complains:
>>>
>>>>     Search pattern not terminated at ./foo line 6.
[...]
>>
>> Here's my test program:
[...]
>> $lb_lang // ($lb_lang = 'en');
>
> Just an observation, I don't know if it makes a difference[1], the OP had
> {} and not () after the //

The difference is that {} doesn't do what the OP wanted, but () does.

	hp


------------------------------

Date: Tue, 12 Aug 2008 19:56:20 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: double slash operator syntax question
Message-Id: <slrnga3jm4.hb1.hjp-usenet2@hrunkner.hjp.at>

On 2008-08-12 01:37, Michael Carman <mjcarman@mchsi.com> wrote:
> Peter J. Holzer wrote:
>> 
>>     $lb_lang // ($lb_lang = 'en');
>
> For some reason I find that very jarring.

So do I. But it was the minimal change which made the OP's
"$lb_lang // {$lb_lang = 'en'};" work.

> I think it's because I prefer to use the low-precedence equivalents
> when doing control flow.

I prefer those, too (maybe just because they save some parentheses), but
in this case I think the aesthetical problem are 

 * $lb_lang is mentioed twice without need:
       $lb_lang //= 'en';
   does what we want and is shorter and clearer
 * A logical operator is used only for control flow: Before 5.10 I
   wouldn't write that as 
       defined $lb_lang  or $lb_lang = 'en'
   but as
       $lb_lang = 'en' unless defined $lb_lang;

>   $lb_lang //= 'en';
>
> is much cleaner, IMHO.

Yes. That's how I would write it.

	hp


------------------------------

Date: Tue, 12 Aug 2008 16:41:39 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <g7seg3$mok$1@reader1.panix.com>

In article <slrng906ar.esc.hjp-usenet2@hrunkner.hjp.at>,
Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>On 2008-07-29 15:57, szr <szrRE@szromanMO.comVE> wrote:
>> Peter J. Holzer wrote:
>>> On 2008-07-28 17:56, szr <szrRE@szromanMO.comVE> wrote:
>>>> Peter J. Holzer wrote:
>>>>> On 2008-07-28 06:12, Jürgen Exner <jurgenex@hotmail.com> wrote:
>>>>>> "szr" <szrRE@szromanMO.comVE> wrote:
>>>>>>> it needs just one decimal digit
>>>>>>
>>>>>> Irrelevant because your typical computer does not use decimal
>>>>>> numbers but binary numbers, just like Peter said.
>>>>>
>>>>> Actually, I didn't write what "a typical computer" uses, just what
>>>>> happens when a binary system is used (which is what perl uses on
>>>>> most (all?) platforms - COBOL uses normally uses decimal).
>>>>
>>>> Even among different types of computers floating point calculations
>>>> are not all done the same. For instance, I have a graphing
>>>> calculator, which is essentially tiny computer with a 6 MHz cpu and
>>>> yet it can do many floating point calculations more accurately than
>>>> my dual core cpu desktop.
>>>
>>> I'm not up to date with calculators (the last one I bought was an
>>> HP-48 20 years ago), but frankly, I doubt that it is more accurate.
>>> It has probably less than 15 digits of mantissa. It probably does its
>>> computations in decimal, which makes them even less accurate, but the
>>> errors *match* *your* *expectations*, so you don't notice then.
>>
>>
>> My point was, on graphing calculators I've used (which has mainly 
>> consisted of Texas Instrument TI-8*'s), the results are what you'd 
>> expect them to me math wise for the most part. That is, what you'd 
>> expect if you were to do it using plain ol' pencil and paper.
>
>Please note the words you are using yourself: "expect" and "for the most
>part". A calcutor uses decimal arithmetic, just like you do when you use
>pencil and paper. So it will produce the correct results in the same
>cases and it will make the same errors - it will do what you expect. But
>that doesn't mean it is more accurate in general - only for decimal
>numbers. 
>
>

You guys gotta be kidding -- calculators working in DECIMAL?

Yeah, I remember a computer that did that -- the IBM 1620, 
did multiplication via a multiplication-table, I was told
way back then (1962 or so).  

(Hey -- I better check that.  Didn't have wikipedia back then!)


Anyway, the only reason ANY (or at least HP) calculators
do correct sine, sqrt, etc, etc today is due to ONE GUY --
a math prof at Berkeley.

(Amazingly, he still seems to be teaching today!)

Bill Kahan.


(I met the guy way back in the 70's, when he was
the world's "Mr Calculator Arithmetic Bug-Finder and Fixer-Upper",
(my terminology), and was consulting for HP (it's why
their stuff worked and no one else's did).)

Here's how I googled for him, and where I then went:


I googled for this:    kahan berkeley math



Linkname: Prof. W. Kahan's web pages (berkeley, calculator-arithmetic
        URL: http://www.cs.berkeley.edu/~wkahan/


Be sure to look at his course-notes.

Here's some sample stuff from his web-page:






   #[1]Edit this page [2]Wikipedia (en) [3]copyright [4]Wikipedia RSS
   Feed [5]Wikipedia Atom Feed

William Kahan

From Wikipedia, the free encyclopedia

   Jump to: [6]navigation, [7]search
   William Morton Kahan
   Born [8]June 5, [9]1933 (1933-06-05) (age 75)
   [10]Flag of Canada [11]Toronto, [12]Ontario
   Nationality Canadian
   Fields [13]Mathematics
   [14]Computer Science
   Institutions [15]University of California, Berkeley
   [16]Alma mater [17]University of Toronto
   Known for [18]IEEE 754
   [19]Kahan summation algorithm
   Notable awards [20]Turing Award
   [21]ACM Fellow

   William Morton Kahan (born [22]June 5, [23]1933, in [24]Toronto,
   [25]Ontario, [26]Canada) is a [27]mathematician and [28]computer
   scientist whose main area of contribution has been [29]numerical
   analysis. Among his colleagues he is known as Velvel Kahan.

   He attended the [30]University of Toronto, where he received his
   Bachelor's degree in 1954, his Master's degree in 1956, and his Ph.D.
   in 1958, all in the field of mathematics.

   Among his many contributions, Kahan was the primary architect behind
   the [31]IEEE 754 standard for [32]floating-point computation (and its
   radix-independent follow-on, IEEE 854) and developed the [33]Kahan
   summation algorithm, an important algorithm for minimizing error
   introduced when adding a sequence of finite precision [34]floating
   point numbers.

   In the 1980s he developed the program "paranoia", a benchmark that
   tests for a wide range of potential floating point bugs.

   He received the [35]Turing Award in 1989, and was named an [36]ACM
   Fellow in 1994.

   Kahan is now a professor of mathematics, computer science, and
   electrical engineering at the [37]University of California, Berkeley,
   and continues his contributions to the [38]ongoing revision of IEEE
   754. He has been called "The Father of Floating Point," since he was
   instrumental in creating the IEEE 754 specification.

   He is an outspoken advocate of better education of the general
   computing population about floating-point issues, and regularly
   denounces decisions in the design of computers and programming
   languages that may impair good floating-point computations.

   He coined the term "The Table-Maker's Dilemma" for the unknown cost
   of rounding [39]transcendental functions:

     "Nobody knows how much it would cost to compute y^w correctly
     rounded for every two floating-point arguments at which it does
     not over/underflow. Instead, reputable math libraries compute
     elementary transcendental functions mostly within slightly more
     than half an [40]ulp and almost always well within one ulp. Why
     can't Y^W be rounded within half an ulp like SQRT? Because nobody
     knows how much computation it would cost... No general way exists
     to predict how many extra digits will have to be carried to
     compute a transcendental expression and round it correctly to some
     preassigned number of digits. Even the fact (if true) that a
     finite number of extra digits will ultimately suffice may be a
     deep theorem." [41][1]

[[42]edit] External links

     * [43]William Kahan's home page
     * [44]portrait picture of Kahan
     * [45]Paranoia for modern graphics processing units (GPUs)
     * [46]Paranoia source code in multiple languages

   See
     * Richard Karpinski. 1985. Paranoia: A floating-point benchmark.
       Byte Magazine 10, 2 (Feb.), 223-235
     * IEEE. 1987. IEEE standard for binary floating-point arithmetic
       [url]. ACM SIGPLAN Notices 22, 2 (Feb.), 9-25
     * An Interview with the Old Man of Floating-Point, 1998-Feb-20
       [47][2]
     * [48]A Conversation with William Kahan, Dr. Dobb's Journal
       November, 1997

   [49]v  o  [50]d  o  [51]e
   [52]A. M. Turing Award [53]laureates

   [54]Perlis (1966) · [55]Wilkes (1967) · [56]Hamming (1968) ·
   [57]Minsky (1969) · [58]Wilkinson (1970) · [59]McCarthy (1971) ·
   [60]Dijkstra (1972) · [61]Bachman (1973) · [62]Knuth (1974) ·
   [63]Newell / [64]Simon (1975) · [65]Rabin / [66]Scott (1976) ·
   [67]Backus (1977) · [68]Floyd (1978) · [69]Iverson (1979) · [70]Hoare
   (1980) · [71]Codd (1981) · [72]Cook (1982) · [73]Thompson /
   [74]Ritchie (1983) · [75]Wirth (1984) · [76]Karp (1985) ·
   [77]Hopcroft / [78]Tarjan (1986) · [79]Cocke (1987) · [80]Sutherland
   (1988) · Kahan (1989) · [81]Corbató (1990) · [82]Milner (1991) ·
   [83]Lampson (1992) · [84]Hartmanis / [85]Stearns (1993) ·
   [86]Feigenbaum / [87]Reddy (1994) · [88]Blum (1995) · [89]Pnueli
   (1996) · [90]Engelbart (1997) · [91]Gray (1998) · [92]Brooks (1999) ·
   [93]Yao (2000) · [94]Ole-Johan Dahl / [95]Kristen Nygaard (2001) ·
   [96]Ron Rivest / [97]Adi Shamir / [98]Leonard Adleman (2002) ·
   [99]Alan Kay (2003) · [100]Vint Cerf / [101]Bob Kahn (2004) ·
   [102]Peter Naur (2005) · [103]Frances E. Allen (2006) · [104]Edmund
   M. Clarke / [105]E. Allen Emerson / [106]Joseph Sifakis (2007)

                          [107]Persondata
   NAME              Kahan, William Morton
   ALTERNATIVE NAMES
   SHORT DESCRIPTION Canadian mathematician and computer scientist
   DATE OF BIRTH     [108]June 5, [109]1933
   PLACE OF BIRTH    [110]Toronto, [111]Ontario, [112]Canada
   DATE OF DEATH    
   PLACE OF DEATH   
   Retrieved from "[113]http://en.wikipedia.org/wiki/William_Kahan"
   [114]Categories: [115]1933 births | [116]Living people | [117]20th
   century mathematicians | [118]21st century mathematicians |
   [119]Numerical analysts | [120]Canadian computer scientists |
   [121]Scientific computing researchers | [122]University of
   California, Berkeley faculty | [123]Turing Award laureates |
   [124]Fellows of the Association for Computing Machinery

<SNIP>

References

   Visible links
   1. http://en.wikipedia.org/w/index.php?title=William_Kahan&action=edit
   2. http://en.wikipedia.org/w/opensearch_desc.php
   3. http://www.gnu.org/copyleft/fdl.html
   4. http://en.wikipedia.org/w/index.php?title=Special:RecentChanges&feed=rss
   5. http://en.wikipedia.org/w/index.php?title=Special:RecentChanges&feed=atom
   6. http://en.wikipedia.org/wiki/William_Kahan#column-one
   7. http://en.wikipedia.org/wiki/William_Kahan#searchInput


  41. http://www.cs.berkeley.edu/~wkahan/LOG10HAF.TXT
  42. http://en.wikipedia.org/w/index.php?title=William_Kahan&action=edit&section=1
  43. http://www.cs.berkeley.edu/~wkahan/
  44. http://www.coe.berkeley.edu/forefront/fall2003/images/kahan.jpg
  45. http://www.cs.unc.edu/~ibr/projects/paranoia/
  46. http://www.netlib.org/paranoia/index.html
 ...

  47. http://www.cs.berkeley.edu/~wkahan/ieee754status/754story.html



I hope this bit of ancient history helps clear up
some of the debate you two are having!


CHEERS!


David


PS: Seriously -- go to his web page


Like, you'll see this:


Files available from this homepage, last updated 3 June 2008

     * [7]Notes for Math. 110, Linear Algebra, Spring Semester 2002.
     * [8]Notes for Math. 221, Matrix Computations, Fall Semester 1996.
     * [9]Notes for Math. H 90, Putnam Problems Practice, Fall Semester 2007.
     * [10]Notes for Math. H 110, Honors Linear Algebra, Fall Semester 2000.
     * [11]Notes for Math. 55, Discrete Math., Spring Semester 1999.
     * [12]Supplementary Notes for Math. 128, Numerical Analysis.
     * [13]Supplementary Notes for Math. 185, Analytic Functions of Complex Variables.
     * [14]Abstracts of the following papers, updated 11 Sept. 2005.(IBM PC Extended ASCII text)
     * [15]Documents relating to IEEE standard 754 for binary floating-point arithmetic, including ...
     * ... why we needed a floating-point standard [16](PDF file)
     * The Improbability of Probabilistic Error Analyses for Numerical Computations [17](PostScript) [18](PDF file)
     * [19]SRTEST is a Fortran/DOS program for testing accuracy of floating-point division
     * [20]Pi-related programs (C and lisp)
     * [21]How to Test Whether SQRT is Rounded Correctly (PostScript)
     * [22]Test programs for the ix87's FIST (Float-to-Integer STore) instruction
     * [23]Beastly Numbers, a paper about two different computers upset in the same way by the same two floating-point numbers
     * On the Monotonicity of some Computed Functions [24](PDF file)
     * Approximate Trisection of an Angle [25](PDF file)
     * Miscalculating Area and Angles of a Needle-like Triangle [26](PDF file)
     * [27]Roundoff Degrades an Idealized Cantilever (PostScript)
     * [28]Roundoff Degrades an Idealized Cantilever (PDF file) See Abstracts above for programs.
     * [29]Gregorian calendar and MATLAB programs for it. (Text files)
     * [30]SIAM's John von Neumann Lecture for 1997 (PostScript)
     * [31]How JAVA's Floating-Point Hurts Everyone Everywhere (PDF file)
     * [32]Matlab's Loss is Nobody's Gain (PDF file)
     * Is there a Small Skew Cayley Transform with Zero Diagonal? [33](PDF file) Presentation version:[34](PDF file)
     * Marketing vs. Mathematics [35](PDF file) [36](PostScript)
     * Mathematics Written in Sand (reproduced legibly)[37](PDF file)
     * About Infinity, for Schoolteachers[38](PDF file)
     * How Blabber-Mouth U-boats Got Sunk in World War II[39](PDF file)
     * What has the Volume of a Tetrahedron to do with Computer Programming Languages?[40](PDF file)
     * Simple Transistorized Ignition Retrofits to Old Cars[41](PDF file)
     * A Device to Warn When Coolant is Low in a Car's Radiator[42](PDF file)
     * The Numerical Analyst as Computing Curmudgeon [43](PDF file)
     * [44]A Logarithm Too Clever By Half. (Text file)
     * Why is Floating-Point Computation so Hard to Debug when it Goes Wrong? [45](PDF file)
     * [46]How Futile are Mindless Assessments of Roundoff in Floating-



Now, go to (I think that's what I did) the first one, 
and you get another list:


pics, Readings and Solutions for the Spring 2002 Final Exam. PDF file
     * [2]Matlab's Inverses of Nearly Singular Hilbert Matrices. PDF file
     * [3]Topics and Solutions for the 2nd Midterm Exam on 1 May 2002. PDF file
     * [4]Sheldon Axler's 1994 article "Down with Determinants". PDF file
     * [5]Solved assignment due Fri. 22 March 2002. PDF file   
     * [6]Topics and Solutions for Math. 110 MidTerm Test, 6 March 2002. PDF file
     * [7]Topics for Math. H110, Fall Semester 2000. PDF file
     * [8]Cross-Products and Rotations in Euclidean 2- and 3-Space. PDF file
     * [9]Axioms for Fields and Vector Spaces. PDF file
     * [10]Solutions to Problems about Axioms for Fields and Vector Spaces. PDF file
     * [11]Notes on 2-Dimensional Spaces. PDF file
     * [12]When is Triangular Factorization Unique?. PDF file
     * [13]The Reduced Row-Echelon Form is Unique. PDF file
     * [14]Vector Spaces, Bases, and Dual Spaces. PDF file
     * [15]Geometry of Elementary Operations. PDF file
     * [16]Geometry of Elementary Operations and Subspaces. PDF file
     * [17]Solutions to problems issued 10 Oct. 2000. PDF file
     * [18]Least-Squares and Bilinear Forms. PDF file
     * [19]Solutions to Problem Set 2. PDF file
     * [20]Solutions for Take-Home Test due 5 Oct. 1998. PDF file
     * [21]Jacobi's formula for the derivative of a determinant. PDF file
     * [22]Gauss-Jordan Inversion of Matrices. PDF file
     * [23]Chio's Trick for Linear Equations with Integer Coefficients. PDF file
     * [24]Euclid's GCD Algorithm for Linear Equations with Integer Coefficients. PDF file
     * [25]Diagonal Prominence. PDF file
     * [26]Solutions for Problems issued 21 Nov. 2000. PDF file
     * [27]Test Problems and Solutions. PDF file
     * [28]How to Recognize a Quadratic Form. PDF file
     * [29]Jordan's Normal Form. PDF file
     * [30]Gargantuan Generalized Inverses. PDF file
     * [31]Notes on Vector and Matrix Norms. PDF file
     * [32]Jensen's Inequality. PDF file
     * [33]Answers for 1998's Final Exam. PDF file
     * [34]Topics to be Covered for the Final Exam, Fall 2000. PDF file
     * [35]Answers for 2000's Final Exam. PDF file
     * [36]Grades for Fall Semester 2000. PDF file
     * [37]Only Commutators have Trace Zero. PDF file
     * [38]Separating Clouds by a Plane; an application of the SVD. PDF file



Lotsa neat stuff there!


(reading all that will keep you busy for a while! ;-)



David




------------------------------

Date: Tue, 12 Aug 2008 16:52:39 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <g7sf4n$sa8$1@reader1.panix.com>

In article <4fc841f2ecdaves@orpheusmail.co.uk>,
Dave Stratford  <daves@orpheusmail.co.uk> wrote:
>In article <slrng8rg3a.pia.hjp-usenet2@hrunkner.hjp.at>,
>   Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>
>> Actually, I didn't write what "a typical computer" uses, just what
>> happens when a binary system is used (which is what perl uses on most
>> (all?) platforms - COBOL uses normally uses decimal).
>
>Obviously written by someone who doesn't know cobol at all well. Cobol has
>been able to use binary since at least 1974. That 'normally' is completely
>wrong, by default cobol wants to use binary. (at least since 1974 it has!)

Yeah, "BCD" (Binary-Coded Decimal).

And I maybe forget, but wasn't that "fixed point" decimal --
fine for maybe accounting and payroll, but sure sucks for
engineering or scientific work.

But isn't that sorta irrevelant, at least to this discussion?

I thought this was about *hardware*, that it worked
base-2.

(Well, software, when you got to sines, sqrts, etc)

David






------------------------------

Date: Tue, 12 Aug 2008 20:30:34 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <slrnga3lma.hb1.hjp-usenet2@hrunkner.hjp.at>

On 2008-08-12 16:41, David Combs <dkcombs@panix.com> wrote:
> You guys gotta be kidding -- calculators working in DECIMAL?

Yes. From "Customize your HP-28", by W.A.C. Mier-Jedrzejowicz, page 57:

    A real number consists of a 5-nybble address followed by the 
    number's 3-digit exponent and 12-digit mantissa, stored back to 
    front. Thus the number
        -7.46454443424E105

    is stored as:
        3 3 9 2 0  5 0 1  4 2 4 3 4 4 4 5 4 6 4 7  9
        \       /  \   /  \                     / \ /
           adr      exp           mantissa        sign
                                                  9 if negative

[...]
> (reading all that will keep you busy for a while! ;-)

Thanks, I'm busy enough as it is ;-).

        hp


------------------------------

Date: Tue, 12 Aug 2008 20:51:53 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <slrnga3mu9.hb1.hjp-usenet2@hrunkner.hjp.at>

On 2008-08-12 16:52, David Combs <dkcombs@panix.com> wrote:
> In article <4fc841f2ecdaves@orpheusmail.co.uk>,
> Dave Stratford  <daves@orpheusmail.co.uk> wrote:
>>In article <slrng8rg3a.pia.hjp-usenet2@hrunkner.hjp.at>,
>>   Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>> Actually, I didn't write what "a typical computer" uses, just what
>>> happens when a binary system is used (which is what perl uses on most
>>> (all?) platforms - COBOL uses normally uses decimal).
>>
>>Obviously written by someone who doesn't know cobol at all well. Cobol has
>>been able to use binary since at least 1974. That 'normally' is completely
>>wrong, by default cobol wants to use binary. (at least since 1974 it has!)
>
> Yeah, "BCD" (Binary-Coded Decimal).
>
> And I maybe forget, but wasn't that "fixed point" decimal --
> fine for maybe accounting and payroll, but sure sucks for
> engineering or scientific work.
>
> But isn't that sorta irrevelant, at least to this discussion?

Nope, because it shows that the number representation isn't some sort of
natural law. It is an engineering decision the language designer or
implementor has to consider. The designers of COBOL decided that
fixed-point BCD arithemetic would be the right choice for a "COmmon
Business Oriented Language". The designers of FORTRAN at about the same
time (and for the same hardware) decided that an unspecified floating
point format was the right choice for a "FORmula TRANslator" (and most
(all?) implementors of FORTRAN then decided on binary floating point
format for speed and accuracy reasons).

Whether binary FP was the right choice for perl is open to debate. I
think it is, but I do have a CS degree[1] and came from C to Perl.
Brian argued in a previous thread about this topic that numbers in Perl
(the language) are decimal and that the use of binary FP in perl (the
interpreter) is more or less a bug in the implementation.

> I thought this was about *hardware*, that it worked base-2.

No, it isn't about hardware. It was about perl specifically (which is
software) and then went on to FP arithmetic in general (which might be
implemented in software or hardware) with calculators as another example
(which makes it software again - I'm not sure about HP's Saturn CPU, but
the TI calculators mentioned in this thread have Z-80 and 68k CPUs
without any hardware FP support).

	hp

[1] And our professor for numerical methods used to start his
    introductory lecture with the sentence: "You can use a computer for
    anything except for computing".


------------------------------

Date: Tue, 12 Aug 2008 17:22:49 +0100
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 5.6 How do I make a temporary file name?
Message-Id: <120820081722491319%brian.d.foy@gmail.com>

In article <86d4kf8ujm.fsf@lifelogs.com>, Ted Zlatanov
<tzz@lifelogs.com> wrote:

> On Sun, 10 Aug 2008 14:21:25 GMT Michael Carman <mjcarman@mchsi.com> wrote: 
> 
> MC> PerlFAQ Server wrote:
> >> 5.6: How do I make a temporary file name?
> >> 
> >> If you don't need to know the name of the file, you can use "open()"
> >> with "undef" in place of the file name.
> 
> MC> This should probably contain a caveat that it requires Perl 5.8+
> 
> MC> Quite a few of the FAQ entries implicitly assume that they're being read
> MC> locally and thus have the necessary version of perl available. Between
> MC> postings here and online versions this isn't a safe assumption.
> 
> If something's posted, it should be the FAQ pertaining to the latest
> Perl, don't you think?

I think that any FAQ should state a version dependency, so I'll fix the
answer :)


------------------------------

Date: 12 Aug 2008 15:40:55 GMT
From: xhoster@gmail.com
Subject: Re: How to check for filetype existence quickly
Message-Id: <20080812114056.836$z4@newsreader.com>

Bart Lateur <bart.lateur@pandora.be> wrote:
> xhoster@gmail.com wrote:
>
> >Globbing will go through all the files in the directory with no
> >possibility of stopping early.
>
> No it won't.

Yes it will.  This has been done to death here lately.

> glob in scalar context is an iterator, it'll return the
> first matching file, or undef on failure.

It might *return* only the first matching file, but it does so only after
it goes through all of them.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


------------------------------

Date: Tue, 12 Aug 2008 20:03:07 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: How to check for filetype existence quickly
Message-Id: <slrnga3k2s.hb1.hjp-usenet2@hrunkner.hjp.at>

On 2008-08-11 14:11, Justin C <justin.0805@purestblue.com> wrote:
> On 2008-08-07, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>> On 2008-08-06 10:18, Justin C <justin.0805@purestblue.com> wrote:
>>> On 2008-08-06, fidokomik <fidokomik@gmail.com> wrote:
>>>> I have directory, say "c:\documents" on Windows or "/home/petr/
>>>> documents" on Linux. In this directory many files are stored with many
>>>> filetypes (extensions), say *.doc, *.txt, *.zip. I need to find fastes
>>>> way how to check if some filetype exist. Now I use routine where I use
>>>> readdir() and return true if passed filetype is first time found but
>>>> when I have huge number of files but passed filetype is not found then
>>>> routine is very slow before return false.
>>>> Any idea?
>>>
>>> ls | egrep doc\|txt\|zip
>>
>> Please not that the OP is passed *one* filetype. So that would be 
>>
> Well spotted. Thanks for pointing it out.
>
> [snip]
>
>>> I know you want to use perl, but perl won't be as fast as this... unless
>>> there are a very, very large[1] number of files.
>>
>> Perl is also likely to be faster for a small number of files - spawning
>> a shell which then spawns two other programs is not exactly a cheap
>> operation.
>
> Gasp! You mean, you don't *always* have a TERM to hand?!  :)

*I* may have, but the script I write don't. They often run as cron jobs,
or web applications or whatever. But in this case the presence or
absence of a terminal is irrelevant: qx(ls | egrep something) has
exactly the same work to do whether there is a terminal or not.

> I see what you mean, I was just thinking quick and dirty, and not
> "write once, use many"... which is a habit I'm trying to cultivate. 

You were arguing with performance. Performance and "quick and dirty"
usually don't mix well.

	hp



------------------------------

Date: Tue, 12 Aug 2008 21:18:03 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: OO Perl
Message-Id: <slrnga3ofc.hb1.hjp-usenet2@hrunkner.hjp.at>

On 2008-08-11 19:37, Matt <mattj.morrison@gmail.com> wrote:
>> That advantage vanishes if you have several projects on several
>> servers using several of your modules. Now you need to keep track of
>> which modules you need to deploy on which server, exactly as if you used
>> modules from CPAN. And unlike CPAN, your system for deployment probably
>> doesn't keep track of dependencies.
>
> I don't quite follow.  If you have multiple projects on multiple
> servers and a module that you're using changes, regardless of if
> you're using a CPAN module or not you'll still have to update ever
> server for every project.

Yep. So you don't win anything by "rolling your own".

> The thing about my OO Module is that there are NO dependencies...

As I said, it seems simpler because you have only one module. But you'll
write other modules which will use your OO module. And then you do have
a dependency: Your other modules depend on your OO module and you have
to install your OO module too if you want to use your other modules.

> the only thing you need is a clean Perl (5.8.8)
> installation.  In my mind I'm trying to compare this to a Java
> Enterprise Archive.  You've got an EAR file that contains a bunch of
> Java Archive files...if you need a new version of a JAR file, you
> download it, and replace that in your ear...it only impacts that one
> application and you don't have to worry about regression testing every
> single application on that server...when you install a Perl module you
> could potentially impact anything on that server unless you install it
> to a specific directory (right?).

You could install all modules for a specific application into a specific
directory. Then installing that module only impacts that application.


> What happens if you've got 200 projects on a server that are all
> unrelated.  If you have a module that you want to install but you
> don't want to have to regression test all other 199 projects you
> install it to a specific directory, or something, right?

If you want to do that, yes. Personally, I don't. I prefer to keep a
single version of each module on the server (and on other servers, too,
if possible).

> What if 50 projects need that module?  Do you have to install that
> module 50 times to those specific directories?

Yes. Same as with the Java. If you want thar Jar-File in 50
applications, you have to include it in 50 EARs, which means that it
will be installed 50 times on the server. (Actually, with the
pointy-clicky Java-IDEs it will probably be included 3 or 4 times in
each EAR, so it will be installed 150 to 200 times ;-)).

> Do you have to reorganize the entire directory structure so that you
> can install a Perl module for a group of projects?

You can certainly do that. @INC gives you all the freedom you need.

> How do you manage a group of 50 that need 1 module and a group of 100
> that need a different module...

I don't understand that question. Isn't your previous sentence the
answer?

> what happens if there is overlap?

Either you define a super group, or you install it for each group which
needs it.

> Sorry for the novel.  If somebody can clarify how this would work
> using CPAN Modules installed the "standard" way, I'd really appreciate
> it.

In a previous posting you wrote that you already know how to do it with
CPAN modules, but that you found that too cumbersome. If you have a
specific question someone here can probably answer it.

	hp


------------------------------

Date: Tue, 12 Aug 2008 17:03:02 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Question about variable scope
Message-Id: <g7sfo6$mld$1@reader1.panix.com>

In article <2vckk.46238$nD.41284@pd7urf1no>,
John W. Krahn <jwkrahn@shaw.ca> wrote:
>nospam wrote:
>> 
>> Subject: Question about variable scope
>
>Perhaps you should read "Coping with Scoping" at 
>http://perl.plover.com/FAQs/Namespaces.html
>
>> In the code snippet below, why can't I access the $nntp variable, unless I
>> instantiate it within the ListGroups() subroutine?
>
>Probably some "action at a distance" is causing it to become undefined.

Spooky!


David




------------------------------

Date: Tue, 12 Aug 2008 15:09:37 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Question in Perl Arrays
Message-Id: <g7s93h$mp8$1@reader1.panix.com>

In article <x7vdz4quus.fsf@mail.sysarch.com>,
Uri Guttman  <uri@stemsystems.com> wrote:
>>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:
>
>  BM> Quoth xhoster@gmail.com:
>  >> 
>  >> On the first point, I'm somewhat confused myself.  I've never fully
>  >> understand what the flip-flop mode does, but I understand enough to avoid
>  >> accidentally using it, so my confusion is safely sequestered.
>
>  BM> It's designed for use with -n. Something like
>
>  BM>     perl -ne'/foo/../bar/ and print'
>
>and i have used it before with while(<FH>) loops. it isn't dedicated to
>-n.
>
>the flip flop op is just a bistable value. it starts out as false (it
>returns a false value) until the left side expression evaluates to
>true. then it returns true until the right side expression evaluates to
>true. the it reverts to false and testing the left side again.
>
>so it keeps track of its state between its evaluations. that is why it
>is called flip flop (after the single bit hardware memory cell that
>remembers its state). bistable is also a good name as it is stable in
>two ways, true and false and needs a trigger (one side or the other
>evaluating to true at the right time.
>
>note that .. only evaluates one side or the other based on its current
>state.
>
>and it is called range even in scalar context because a (the most?)
>common use is to select a range of lines from a stream. it even has a
>builtin test against $. if either side is a literal number.
>
>uri

What about when there's three dots, "..."?

(This thread is shaping up to be a pretty good doc
on flip=flop, with contexts.)

THANKS!

David




------------------------------

Date: Tue, 12 Aug 2008 16:41:05 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Question in Perl Arrays
Message-Id: <hhn8n5-bm7.ln1@osiris.mauzo.dyndns.org>


Quoth dkcombs@panix.com (David Combs):
> 
> What about when there's three dots, "..."?

I think perlop is pretty clear on that point, at least:

| [".."] can test the right operand and become false on the same
| evaluation it became true (as in awk), but it still returns true once.
| If you don’t want it to test the right operand till the next
| evaluation, as in sed, just use three dots ("...") instead of two.  In
| all other regards, "..." behaves just like ".." does.

so given the input

    FOOBAR
    BAZ
    BAR
    QUUX

this
    
    perl -ne'print if /FOO/../BAR/'

will print

    FOOBAR

only, whereas this

    perl -ne'print if /FOO/.../BAR/'

will print

    FOOBAR
    BAZ
    BAR

that is, it ignores the fact that the 'start matching' line is also a
valid 'stop matching' line. That is the only difference between the two.

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                            ben@morrow.me.uk


------------------------------

Date: Tue, 12 Aug 2008 12:28:33 -0700
From: jaycx2.3.calrobert@spamgourmet.com.remove (Robert Maas, http://tinyurl.com/uh3t)
Subject: Re: The Importance of Terminology's Quality
Message-Id: <rem-2008aug12-003@yahoo.com>

John W Kennedy <jwke...@attglobal.net> wrote:
JWK> Into the 60s, indeed, there were still machines being made
JWK> that had no instruction comparable to the mainframe BASx/BALx
JWK> family, or to Intel's CALL. You had to do a subprogram call by
JWK> first overwriting the last instruction of what you were
JWK> calling with a branch instruction that would return back to
JWK> you.

That's not true, that you needed to do that, that there was no
other way available. The subroutine linkage I invented for S.P.S.
(Symbolic Programming System, i.e. IBM 1620 assembly language) was
to reserve a 5-digit space immediately before the subroutine entry
point for storing the return address. So the caller needed to know
only one address, the entry point, and do both store-return-address
and jump relative to that address, rather than needing to know both
the entry point and the last-instruction-JUMP-needs-patch address
as independent items of information. So calling a subroutine was
two instructions (pseudo-code here):
   literal[nextAdrOfSelf} -> memory[SubrEntryPoint-1]
   jump to SubrEntryPoint
and returning from a subroutine was two instructios:
   copy memory[SubrEntryPoint-1] -> memory[here + 11]
   jump to 00000 ;These zeroes replaced by return address just above
Of course if you needed to pass parameters and/or return value,
that was handled separately, perhaps by reserving additional
storage just before the return address. Of course this methodology
didn't support recursion.

So my method required one extra instruction per return point, but
allowed multiple return points from a single subroutine, and
allowed "encapsulation" of the relation between entry point and
return point.

Note: On IBM 1620, instructions and forward-sweeping data records
were addressed by their *first* digit, whereas arithmetic fields
were addressed by their *last* digit, the low-order position, to
support natural add-and-carry operations. Storage was decimal
digits, with two extra bits, flag to indicate negative value (if in
low-order position) or high-order-end (if in any other position),
and parity. Values larger than nine were reserved for special
purposes, such as RECORD MARK used to terminate right-sweep data
records. Because of that, the low-order position of the return
address and the first digit of the machine instruction at the
subroutine entry point differed by only machine address, hence the
SubrEntryPoint-1 instead of SubrEntryPoint-5 you would otherwise
expect.

Hmm, I suppose if I had thought it out more at the time, I might have
done it slightly differently:

Entry point like this:
         jump 00000 ;Patched by caller to contain return address
  Entry: ...(regular code)...
          ...

Each return point like this:
         jump Entry-12


I wonder if anybody ever implemented a stack on the IBM 1620?
Probably not, because it would take a lot more machine instructions
to push and pop, and if you weren't writing anything recursive then
extra work for no extra benefit except saving a few digits of
memory if your maximum stack depth is less than the total number of
subroutines you have loaded, except the extra instructions more
than kill off the storage savings.

Hmm, I suppose you could have a auxilary function that serves as
trampoline for stack-based call and return. To call, you move your
own return address and address of subroutine to fixed locations in
low memory then jump to the call trampoline, which pushes the
return address onto the stack and jumps at entry address. To
return, you just jump to the return trampoline, which pops the
return address off the stack and jumps at it. The trampoline,
occuping memory only *once*, could afford to have code to safely
check for stack over/under flow.


------------------------------

Date: Tue, 12 Aug 2008 18:40:45 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: what is the option '/gee' used for in the RE expression?
Message-Id: <thu8n5-jkf.ln1@osiris.mauzo.dyndns.org>


Quoth "Jking" <jiangjun_maillist@tom.com>:
> 
> But I wonder what is meaning of the RE options /gee?

See "Regexp Quote-Like Operators" in perldoc perlop.

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                           Heraclitus
  ben@morrow.me.uk


------------------------------

Date: Tue, 12 Aug 2008 12:51:09 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: what is the option '/gee' used for in the RE expression?
Message-Id: <48a1cd8e$0$87069$815e3792@news.qwest.net>

Jking wrote:
> Hi,
> 
> You perl gurus,  I am reading the code of blosxom,  but get stumped at the 
> following line:
> 
> ======================================================================
> 
>   # Define default interpolation subroutine
>   $interpolate =
>     sub {
>       package blosxom;
>       my $template = shift;
>       $template =~
>         s/(\$\w+(?:::)?\w*)/"defined $1 ? $1 : ''"/gee;
>       return $template;
>     };
> 
> =======================================================================
> 
> the interpolate function is used to substitute the variable value in the 
> context for the occurrence of variable names in $template string.
> 
> But I wonder what is meaning of the RE options /gee?
> 
> Any one can help me?

You answered your own question. The interpolate subroutine does that
by using /ee.

If you want more details:

perldoc -q "How can I expand variables in text strings"


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1790
***************************************


home help back first fref pref prev next nref lref last post