Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • The title I'm getting is "Sun 22 May 2005 08:57:22 PM EDT (Mon, 23 May 2005 08:57:22 GMT)". The difference between EDT and GMT is 4 hours, not 12. But perhaps it's some other EDT you're referring to. (Plus it's confusing to use AM/PM for the EDT times and 24-hour time (apparently) for the GMT.)
    • That's very strange. All the time math is done in your browser, which should ideally know its correct TZ offset. But I'll poke around a bit and see if I'm parsing the date wrong or something. What browser are you using?
  • I haven't even finished HOP yet, but I just digested a large Javascript tome [oreilly.com] for work reasons. JS has a few higher-ordery features that Perl doesn't.

    An interesting twist on eval, Function() creates a function reference out of an array of strings.

    And this JS 1.5 syntax, which gives an anonymous closure a temporary name so it can refer to itself.

    var f = function fact(x) { if (x <=1) return 1; else return x*fact(x-1); }

    Despite appearances, there is no fact(). That was just a name for use duri

    • One is tempted to do this:

      my $f = sub { ($_[0] <=1) ? 1 : ( $_[0] * $f->($_[0] - 1)) };
      print $f->(4);

      But that doesn't work, because sub is defined outside the scope of $f. So you've got to do this:

      my $f;
      $f = sub { ($_[0] <=1) ? 1 : ( $_[0] * $f->($_[0] - 1)) };
      print $f->(4);

      That works!

      (GC note: now $f and that sub constitute a circular data structure, so you need to do $f='whatever'; (or just undef($f)) to break the circularity.)

      • Huh. Now I wonder why what I was trying didn't work. That seems relatively straightforward, with the slight inconvenience of defining the variable first. Callee was another weirdness I noticed too. Thanks.
    • Also:
      var f = function (x) { if (x <=1) return 1; else return x * arguments.callee(x-1); };