More UNIVERSAL fun, now with closures added!

2001-07-09 Thread Ilmari Karonen
my $sub = can($pkg, shift); $sub && sub { $sub->($pkg, @_) }; } } -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "Wow, this theory not only proves that Bill Gates is evil, but it proves that our basic number system is flawed. THAT'S AMAZING!"

Re: Orwants Markov-R-P-Scissors-game?

2001-07-11 Thread Ilmari Karonen
sure that it won't lose very much, as it should settle into a random strategy if playing against an opponent it can't successfully predict. -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "This is why Denver had a gigantic red-light district downtown in the early days. A man may l

Re: reparsing the ambiguous

2001-07-11 Thread Ilmari Karonen
ated like $H{cheese} = 'ducati'; $A[5] = \%H; $S = \@A; $name = \$S; right? I'm not exactly sure what, if anything, this is an argument for. -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "This must be a use of the word 'obvious' of which I was previously unaware." -- Charles Martin in rec.arts.sf.science

Re: End of block actions WITHOUT magic lexicals?

2001-07-23 Thread Ilmari Karonen
not defined"; ok( defined $self->foo() ); } Actually, it's not even ugly at all, really. True, the guts are showing, but that's quite common in Perl. And it involves no new syntax that would have to be looked up in the docs. -- Ilmari Karonen - htt

Re: End of block actions WITHOUT magic lexicals?

2001-07-29 Thread Ilmari Karonen
d the "solution" seems obvious too. Export $TODO, so that it gets aliased to every package where ok() is available. -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "You know why psych experimenters often use grad students as subjects, right? It's because you have to feed

Re: End of block actions WITHOUT magic lexicals?

2001-07-31 Thread Ilmari Karonen
On Sun, 29 Jul 2001, Michael G Schwern wrote: > On Sun, Jul 29, 2001 at 12:38:29PM +0300, Ilmari Karonen wrote: > > And the "solution" seems obvious too. Export $TODO, so that it gets > > aliased to every package where ok() is available. > > C would work, but

Re: Sorting in-place

2001-08-06 Thread Ilmari Karonen
d just simply write return; instead. -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "It's possible to write a Perl program that simulates a universal Turing machine, so, yes, your point is both valid and correct." -- Greg Bacon in comp.lang.perl.misc

Re: Sorting in-place

2001-08-06 Thread Ilmari Karonen
On Mon, 6 Aug 2001, Marc wrote: > On Mon, Aug 06, 2001 at 01:21:12PM +0300, Ilmari Karonen <[EMAIL PROTECTED]> wrote: > > Shouldn't that rather be > > > > use constant NOTHING => (); > > yes, I noted that as well (but for some reason I forgot to re

Re: Sorting in-place

2001-08-07 Thread Ilmari Karonen
On Mon, 6 Aug 2001, Andrew Pimlott wrote: > On Tue, Aug 07, 2001 at 12:27:50AM +0300, Ilmari Karonen wrote: > > () is an empty list, and the fact that an empty list > > constant evaluates to undef in *scalar* context is an explicit feature > > of constant.pm. > >

Re: Fun with Regexes

2001-08-13 Thread Ilmari Karonen
almost two orders of magnitude, and with input number 5 the "1 while s/\s\z//" and "s/\s+\z//" performances are equal to within a factor of 2. I added the sexeger entry after I had already done most of the testing, so all I can say about it is that it doesn't beat "1

Re: Fun with Regexes

2001-08-13 Thread Ilmari Karonen
On Mon, 13 Aug 2001, Ian Phillipps wrote: > On Mon, 13 Aug 2001 at 12:13:23 +0300, Ilmari Karonen wrote: > > > * For any nontrivial text input, the "1 while s/\s\z//" approach is by > >far the fastest. > > How about "chop while /\s\z/" ? Fa

Re: JAPHs with no unsightly letters or numbers

2001-08-14 Thread Ilmari Karonen
On Tue, 14 Aug 2001, Larry Shatzer wrote: > > You confused deparse, good job :o) Although it's not really that hard, particularly for older versions of B::Deparse. (The one in bleadperl deparses this just fine.) -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "That wasn

Re: how to much an URL?

2001-08-17 Thread Ilmari Karonen
d above -- it probably gains very little over: m{([a-z][a-z0-9+.-]+:[a-z0-9;/?:@&=+$,_.!~*'()%-]+)}ig; and in fact this may be more robust when dealing with URLs containing non-standard escape codes. By the way, depending on the application, you probably want to add # to the list of acceptable character

Re: Looking for Perl JAPH scripts site, etc.

2001-08-19 Thread Ilmari Karonen
/ o->op_ppaddr = PL_ppaddr[OP_PREINC]; break; case OP_POSTDEC: o->op_type = OP_PREDEC; /* pre-decrement is faster */ o->op_ppaddr = PL_ppaddr[OP_PREDEC]; break; -- # Ilmari Karonen -- http://www.sci.fi/~iltzu/ s''n4|9|21|3|n1\

Re: World's First JAPH

2001-08-22 Thread Ilmari Karonen
ome flexibility > in rules makes for more Japhs. Printing to either STDOUT > or STDERR is allowed. >- It doesn't print anything else. So is this .sig a JAPH, then, or is it not? :-) -- # Ilmari Karonen -- http://www.sci.fi/~iltzu/ s''n4|9|21|3|n1\2||2|(_-<2_|4_`

Re: evaluating assigning to a list in if( ) statement

2001-09-11 Thread Ilmari Karonen
ist contains only one array. Yes, this is an example of those funny unflattened lists like the one in "\(LIST)".) The Nit Protection Society, however, is protesting this discussion... -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "Weetabix, mixed with milk and secretly sculpted on to t

Just->another->Perl->hacker

2001-09-23 Thread Ilmari Karonen
package UNIVERSAL;sub print {map{s;::; ;g;print}@_=@_}AUTOLOAD{${(caller 0)[3]}} Just->another->Perl->hacker->print(",\n"); -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "TIMTOWTDI, but did you have to pick the ugliest way you could find?"

RE: Just->another->Perl->hacker

2001-09-24 Thread Ilmari Karonen
upposed to autoload. This name, of course, then gets treated as the name of a package, and another method is called on it, and so on... So this code isn't "use strict" clean. It does, however, run without any extra output even with warnings enabled. -- Ilmari Karonen - http://www.s

Re: [Not Fun] (Perl) WWW-Authenticate: NTLM using LWP::* or Net::* ????

2001-10-20 Thread Ilmari Karonen
On Sat, 20 Oct 2001, Bill Jones wrote: > WWW-Authenticate: Negotiate > WWW-Authenticate: NTLM [snip] > Client-Warning: Unsupported authentication scheme 'ntlm' Okay, obvious question: Are authentication scheme names case-sensitive? -- Ilmari Karonen - http://www.sci

Re: fore review ;-) -- Elapse.pm

2001-11-28 Thread Ilmari Karonen
long with any value the variable may hold, as well). Looks a lot like Time::Stopwatch, except for the fancy output. I hope you don't mind me stealing some ideas -- it's about time I got a new version released, with new bells and whistles. -- Ilmari Karonen - http://www.sci.fi/~iltzu/ &quo

Re: Sorted Code

2001-12-14 Thread Ilmari Karonen
sions 5.005_03 and 5.7.1: perl -e 'print map chr, 0, 4 .. 255' | perl -c That's a total of 253 out of 256 characters, which seems unbeatable. No, I've no idea why that works. Explanations gladly accepted. -- Ilmari Karonen - http://www.sci.fi/~

Re: Sorted Code

2001-12-15 Thread Ilmari Karonen
On Fri, 14 Dec 2001, Jeff 'japhy' Pinyan wrote: > On Dec 14, Ilmari Karonen said: > >On Thu, 13 Dec 2001, Jeff 'japhy' Pinyan wrote: > >> On Dec 14, [EMAIL PROTECTED] said: > >> > >> >what is the longest piece of perl code $c whic

Re: Golf challenge: decode CETI message

2002-01-12 Thread Ilmari Karonen
ke it yhorter and more viyible on my yyytem." ? Besides, aren't single quotes special for s/// and y/// anyway? I think what Keith _really_ meant was tr[\0\xff][ @] or equivalent. BTW, I'd like to congratulate you for producing worst-case backtracking behavior in my mental parser

Re: Fwd: Re: interesting typo I couldn't see

2002-02-23 Thread Ilmari Karonen
ecurity, while keeping the code readable for yourself. Assuming, of course, that the next guy after your job won't be a lisp programmer.) -- Ilmari Karonen, "virtuaalisihteeri", Luonto-Liitto

Re: Fisher-Yates shuffle

2002-04-04 Thread Ilmari Karonen
it's a little extra work, but it's no worse than what you have to do with s///. Turning an in-place shuffle into copy-and-shuffle is easy, the other way is impossible. -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "Signal handlers are known to be broken in perl. Did you expect them to somehow get unbroken when ITHREADS is enabled?" -- Gurusamy Sarathy on the perl5-porters list

Re: Fisher-Yates shuffle

2002-04-04 Thread Ilmari Karonen
signments where the left and right hand sides overlap are handled as special cases. It may be that this special handling has been implemented in a suboptimal way. Or maybe it's just overhead from the generic list assignment code as compared to scalar assignment.) -- Ilmari Karonen - http

Re: Fisher-Yates shuffle

2002-04-05 Thread Ilmari Karonen
On Fri, 5 Apr 2002 [EMAIL PROTECTED] wrote: > On Fri, Apr 05, 2002 at 12:17:27AM +0300, Ilmari Karonen wrote: > > The point of taking a reference is that the Fisher-Yates algorithm is an > > in-place shuffle. If your array happens to be a couple of megabytes in > > size, yo

Re: Fisher-Yates shuffle

2002-04-09 Thread Ilmari Karonen
On Fri, 5 Apr 2002 [EMAIL PROTECTED] wrote: > On Fri, Apr 05, 2002 at 06:30:17PM +0300, Ilmari Karonen wrote: > > > > Well, map does allow in-place modification. I seem to recall you taking > > advantage of this feature before, and defending it quite vehemently >

Re: Fisher-Yates shuffle

2002-04-12 Thread Ilmari Karonen
On Tue, 9 Apr 2002 [EMAIL PROTECTED] wrote: > On Tue, Apr 09, 2002 at 01:49:01PM +0300, Ilmari Karonen wrote: > > On Fri, 5 Apr 2002 [EMAIL PROTECTED] wrote: > > > > > > sub shuffle { > > > for (my $i = @_; $i;) { > > > m

Re: Fisher-Yates shuffle

2002-04-15 Thread Ilmari Karonen
hird step is dealing with the inevitable backwards compatibility issues... Want to submit a patch? -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "I once bought a 'wand of long blue line creation'. That's what it said on the side and it worked, too." -- Jonathan L Cunningham in rasfc

Re: shortest test for truth & false assignment

2002-05-28 Thread Ilmari Karonen
*a = *|; if ($a--) { do_something(); } Just make sure you don't select a different filehandle somewhere... -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "I admit, the original poster didn't say they wanted a solution that was good. They just said they wanted it to be mu

Re: Perl Challenges, Anywhere?

2002-08-31 Thread Ilmari Karonen
picking up a new load of stuff to deliver. And Perl isn't that slow. I'd be more worried about the 64MB limit... -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "We have argued that unskilled individuals suffer a dual burden: Not only do they perform poorly, but they fail to realiz

Re: Perl Challenges, Anywhere?

2002-09-09 Thread Ilmari Karonen
to? And a test client to observe? Seriously, your protocol might well be secure, or at least secure enough for the job it's doing. But we can't tell from that sample. (Or, if we could, it definitely wouldn't be secure by any standards.) -- Ilmari Karonen - http://www.sci.fi/~i

Re: Converting a textfile-like string to an array and back

2003-02-08 Thread Ilmari Karonen
n extra > element onto the string. Yes it does work. Try it. Remember, $tail _cannot_ be undefined, since it was returned by split(). @lines _can_ be empty, but that case works as it should. -- Ilmari Karonen http://www.sci.fi/~iltzu/

Re: perl syntax oddity

2003-09-18 Thread Ilmari Karonen
accept a glob that way: sub getaglob {*foo} $foo = "pong\n"; for ${&getaglob} ("ping ") { print $foo } print $foo; works, printing "ping pong", while: sub getaglob {*foo} $foo = "pong\n"; { local ${&getaglob} = "ping "; print $foo } print $foo; fails with "Can't localize through a reference"! Weird. -- Ilmari Karonen

/$sudoku/

2006-04-20 Thread Ilmari Karonen
ous from the code, is an 81-character string listing the numbers in left-right, top-down order, with "_" for blanks. The while loop mangles it into the proper format for the regexp (81 lines, each listing the allowed numbers for the corresponding cell) and outputs the solution in the same format as the input. -- Ilmari Karonen

Re: /$sudoku/

2006-04-20 Thread Ilmari Karonen
Ilmari Karonen wrote: Sudoku solvers are old hat, of course, but this one is a bit different: it's a regexp. I suppose someone may have done this before, but if so, I haven't seen it. It's grossly inefficient, of course, solving the puzzle entirely by guesswork and backtrack

Re: /$sudoku/

2006-04-20 Thread Ilmari Karonen
Robert C. Helling wrote: On Thu, 20 Apr 2006, Ilmari Karonen wrote: Ilmari Karonen wrote: Incidentally, here's the hardcoded-givens version. It's indeed quite a lot faster the generic version -- I've yet to find a puzzle that would take more than 0.1 seconds to solve on my wor

Re: Error puzzler

2006-09-24 Thread Ilmari Karonen
Michael G Schwern wrote: I have a solution! DON'T USE $_ [1] [1] Except in map and grep and the magic while(<>) where its localized. Didn't this thread start from the fact that $_ is _not_ localized in the magic while(<>) loop? -- Ilmari Karonen