home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7376 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  3.0 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Is this a perl bug?
  5. Message-ID: <1992Dec12.072651.653@netlabs.com>
  6. Date: 12 Dec 92 07:26:51 GMT
  7. References: <1992Dec6.232905.13545@reed.edu> <1992Dec8.175616.20198@netlabs.com> <9212111642.AA27958@brimstone.unipalm.co.uk>
  8. Sender: news@netlabs.com
  9. Organization: NetLabs, Inc.
  10. Lines: 57
  11. Nntp-Posting-Host: scalpel.netlabs.com
  12.  
  13. In article <9212111642.AA27958@brimstone.unipalm.co.uk> ian (Ian Phillipps) writes:
  14. : lwall@netlabs.com (Larry Wall) writes:
  15. : >And why have I put off formats for so long?  Guess where a lot of the
  16. : >most ancientest and most decrepitudinous code in Perl is.
  17. : Why not write them in perl?
  18. : A few quick hacks, an eval, and away you go. Maybe.
  19.  
  20. Well, in actual fact, in Perl 5, the tokener turns a format into a
  21. strange sort of subroutine, which calls one or more statements
  22. containing a list operator called "formline".  You can call formline
  23. yourself if you want to do something funky.
  24.  
  25. Similarly, when you say "\u\L$foo\E$bar", the tokener turns that into
  26. (ucfirst(lc($foo)) . $bar).  You can call uc(), lc(), ucfirst() and
  27. lcfirst() yourself if you like.  Similarly, `cat $foo` turns into
  28. something like backtick('cat ' . $foo), though I haven't actually put
  29. in a keyword to access that function yet.  The m// and s/// stuff works
  30. similarly.
  31.  
  32. Anyway, formats are completely rewritten now, and work, and I'm at 95.89%.
  33. I'm now to the point where I have to start putting in lexical scoping
  34. and references to make any more progress.
  35.  
  36. The 3 tests that are still failing use most of the cpu time they would
  37. anyway, so I compared the timings of Perl 4 on the regression tests
  38. with Perl 5.  With both compiled -g -DDEBUGGING, I got:
  39.  
  40.     Perl4: 11.4u 16.8s 0:48
  41.     Perl5:  9.4u 10.5s 0:36
  42.  
  43. For something that I've done almost no optimization on except for constant
  44. folding, that's not too shabby...
  45.  
  46. I suspect that the difference in system time comes from longjmp() avoidance.
  47.  
  48. : BTW - I've used most bits of Perl (but *foo='bar' still has me
  49. : baffled), but I've never actually *used* formats - although they've
  50. : appeared in early drafts of some of my efforts.
  51. : In every case I've met, "printf" does what I want and formats don't,
  52. : mostly because of what happens when the variable is too wide for the
  53. : field - I'm in the "keep the data a blow the format" party.
  54.  
  55. Hmm, I might be able to give you overflowable fields with the new
  56. format code.  What about something like @<<<<*, analogous to the @*
  57. thingy?  I suppose that would imply a minimum width of 2 for @*, but
  58. that's probably okay, since it would generally turn into 2 spaces that
  59. would get eaten up before the newline anyway.
  60.  
  61. One could also imagine specifying that as *<<<<<, since ^<<<<* doesn't
  62. really make much sense, but I don't think I want to introduce another
  63. initial metacharacter.  On top of which, ^###.#* does make some sense,
  64. not to mention cents.
  65.  
  66. Larry
  67.