Here is but one snippet to illustrate why working with
_sps_'s perl code can sometimes hurt my brain:
--
It was when I realized he was using side-effects on $list to communicate between the various repetitions of the substitutions caused by /g that my brain started to hurt...
local ($list)='';
s#(^|\n\n+)(\t?)##"\n".('<p>','<ul><li>','</ul><p>','<li>')[length($list) * 2 + length($2)].($list=$2, '')#gse;
s#$#</ul>#s if $list;--
It was when I realized he was using side-effects on $list to communicate between the various repetitions of the substitutions caused by /g that my brain started to hurt...
no subject
Date: 2006-02-15 06:14 pm (UTC)(Of course, what this is about is that the $n substitutions are fatally flawed in that they don't provide the tree-structured namespace necessary to deal with iteration. Larry's also a bit short-sighted on occasion.)
(And I didn't compile any of the input data into regexps, did I? See how good I'm being today?)
no subject
Date: 2006-02-15 06:15 pm (UTC)no subject
Date: 2006-02-15 06:39 pm (UTC)It looks like changing the code to output wiki-format files will be trivial, now that I actually understand what the existing code does.
no subject
Date: 2006-02-15 07:59 pm (UTC)no subject
Date: 2006-02-16 12:02 pm (UTC)Unless I am mistaken and I am missing out on a small detail. Wouldn't surprise me.
no subject
Date: 2006-02-16 12:22 pm (UTC)no subject
Date: 2006-02-16 12:46 pm (UTC)Perl 5 didn't change all that much in the last 5 years, that I know of. Added a few keywords, but nothing too serious (like "our", the opposite to "my", but it's just syntax-sugar).
In this particular case, the "local" wouldn't hurt, and would actually provide what would look like a local variable. But if you start calling some of the functions in the same package, woo, you can get into fun trouble!
no subject
Date: 2006-02-16 03:25 pm (UTC)Though the following does work, which is something:
my %a = (x => 1); { local $a{x} = 0; print "Zero: $a{x}\n" } print "One: $a{x}\n"Experiments show, however, that pos() and substr(), though lvalues, are not local()isable. This is sad. Localising pos(), in particular, would be a great comfort.
no subject
Date: 2006-02-16 03:45 pm (UTC)I don't understand what is surprising about that piece of code. "local" saves the value, so you can fiddle with it locally, and restores it at the end of the scope. Yep, that's what it did, sure enough. It's a pretty clear (and very useful when there are a lot of global variables, like I think it was mostly in the time of Perl 4) mechanism, it's just quite unfortunately named. Maybe it should have been "localize", to express more that it's something you do to an existing variable, rather than declaring a brand-new local variable?
no subject
Date: 2006-02-16 03:57 pm (UTC)The programme that comes from is probably more than five years old (I don't think I was at McGill yet), but the origin of the snippet dates back more like fifteen years - we used Perl for sgml wrangling in Chicago, back when gopher was the it.
no subject
Date: 2006-02-16 05:56 pm (UTC)no subject
Date: 2006-02-16 03:38 pm (UTC)no subject
Date: 2006-02-16 03:44 pm (UTC)The next time it happens, I'll ask them how they came up with it.
no subject
Date: 2006-02-16 03:49 pm (UTC)