Re: tri-state flags

2001-12-05 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Bart Lateur [EMAIL PROTECTED] wrote: I often use tri-state flags, with possible value true (1), false (0), or undetermined (undef). The question is: how do you test for one of the flags, in particular for 0, without warnings? Here's one way :) use Data::Dumper;

Re: tri-state flags

2001-12-09 Thread Yitzchak Scott-Thoennes
Bart Lateur [EMAIL PROTECTED] wrote: grep { defined !$_ } FLAG To extend that, if you want to test for (state(s)) use (code): state code undef !defined FLAG 0 grep defined !$_, scalar FLAG; 1 FLAG undef,0 !FLAG undef,1 grep !defined || $_, scalar FLAG; 0,1 defined

Interactive golf hole

2002-01-08 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Yanick [EMAIL PROTECTED] wrote: You provide the course, I smack the balls. I prefer (at least sometimes) to see golf worked out interactively, on the list. Here's a hole: A file has 0 or more fields on each line. Fields are separated by 1 or more whitespace

Re: Interactive golf hole

2002-01-08 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote: On Jan 8, Yitzchak Scott-Thoennes said: I prefer (at least sometimes) to see golf worked out interactively, on the list. I'm not sure I understand. Shall I show my code? Yes. -n $\=$/;$,=':';print/([^]*|[^\s#]+)\s

Re: Interactive golf hole

2002-01-08 Thread Yitzchak Scott-Thoennes
Wesley Darlington [EMAIL PROTECTED] wrote: -p s/\s*(([^]*)|((\S*?)#.*)|(\S+))\s*/$2$4$5:/g,s/:+$/\n/ That's downright clever. I think the approach could be a winner, but as is it removes trailing empty fields: x becomes: x instead of: x:

Re: Interactive golf hole

2002-01-08 Thread Yitzchak Scott-Thoennes
Wesley Darlington [EMAIL PROTECTED] wrote: -p s/\s*(([^]*)|((\S*?)#.*)|(\S+))\s*/$2$4$5:/g,s/:+$/\n/ That's downright clever. I think the approach could be a winner, but as is it removes trailing empty fields: x becomes: x instead of: x: Now that someone has braved removing the quotes in

Re: Interactive golf hole

2002-01-08 Thread Yitzchak Scott-Thoennes
Ronald J Kimball [EMAIL PROTECTED] wrote: Here's my current solution, at 64: -pl $_=join':',grep defined,/([^]*)(?![^\s#])|([^\s#]+)|#.*/g Originally I had $_.0 instead of defined, but I realized that that skips empty fields, i.e. . Is there a shorter way to test for defined? Not that I can

Re: Interactive golf hole

2002-01-09 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Yitzchak Scott-Thoennes) wrote: Ronald J Kimball [EMAIL PROTECTED] wrote: Here's my current solution, at 64: -pl $_=join':',grep defined,/([^]*)(?![^\s#])|([^\s#]+)|#.*/g Originally I had $_.0 instead of defined, but I realized that that skips

Re: A perverse use of the glob function

2002-01-30 Thread Yitzchak Scott-Thoennes
Bart Lateur [EMAIL PROTECTED] wrote: If it should be just fooa, then I'd like to mote that solutions based upon this trick would be disqualified, because they won't work on all reasonable systems. :-) perl56delta, aka perldelta for v5.6 5.6.1, says (n.b. this line = valid perl) File

Re: substitution question

2002-02-01 Thread Yitzchak Scott-Thoennes
John W. Krahn [EMAIL PROTECTED] wrote: On Friday 01 February 2002 02:26, Bart Lateur wrote: $date =~ s{(\d+)/(\d+)/(\d+)}{sprintf '%02d/%02d/%d', $1, $2, $3}e; $date = sprintf '%02d/%02d/%d', $date =~ m|(\d+)/(\d+)/(\d+)|; That's very different. Bart's doesn't translate if $date

Re: TPR(0,1)...at last

2002-03-01 Thread Yitzchak Scott-Thoennes
References: [EMAIL PROTECTED] Lines: 13 In article [EMAIL PROTECTED], Jerome Quelin [EMAIL PROTECTED] wrote: On Vendredi 1 Mars 2002 15:42, Philip Kendall wrote : Do we have to deal with the case of the input having leading zeros? Sure. Excerpt from the rules: You may assume that the first

Re: rethinking printf

2002-03-06 Thread Yitzchak Scott-Thoennes
In article p05100339b8abfb25cfdf@[192.168.254.205], Rich Morin [EMAIL PROTECTED] wrote: Note that I'm suggesting a new function name because printf has a little-used capability that could conflict with my proposed syntax: The format string is reused as often as necessary to satisfy the

Re: rethinking printf

2002-03-10 Thread Yitzchak Scott-Thoennes
[EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Lines: 17 In article [EMAIL PROTECTED], Uri Guttman [EMAIL PROTECTED] wrote: i disagree. but we shall see if larry is listening to this thread and will back away from hash interpolation or take some of our suggestions that make it work

Re: rethinking printf

2002-03-10 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Brent Dax [EMAIL PROTECTED] wrote: There's only a clash if you double-quote the format string anyway, which is a rare thing to need to do at all. I'd expect that a hefty percentage of format strings have a \n.

Re: Golf spectators

2002-03-18 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Dave Hoover [EMAIL PROTECTED] wrote: Piers wrote: So, how about having some way of letting spectators see the entries. I can't think of a good way to do this *during* the tournament. I know if I was golfing, there's no way I could resist looking at the

Re: Golf spectators

2002-03-24 Thread Yitzchak Scott-Thoennes
In article Pine.LNX.3.96.1020319100459.13630A-10@gentoo, Stephen Turner [EMAIL PROTECTED] wrote: On Mon, 18 Mar 2002, Yitzchak Scott-Thoennes wrote: So set up a list that all solutions go to upon submission. No players would subscribe to such a list, and no archive would be available

Re: First differing char in two strings

2002-04-11 Thread Yitzchak Scott-Thoennes
($a ^ $b) =~ /^(\0*)/ length $1 Whether they give the same value depends on the values of $a and $b. Try it with $a = 'abcdef' and $b = 'abCdef', for example. To work with any $a and $b, you should play it safe and say: $a^$b. Otherwise the used-in-numeric-context gremlins will eat your

Re: Whitespace and Blocks

2002-04-18 Thread Yitzchak Scott-Thoennes
I'd just like to congratulate everyone on maintaining civility in what could have been a very incendiary thread. (I did see one ad hominem, but that's pretty good for 50 posts and counting.)

Re: shortest test for truth false assignment

2002-05-22 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Scott Wiersdorf [EMAIL PROTECTED] wrote: $a $a-- do { do_something(); ... } Two questions: a) can it be shortened to fewer characters? and b) is there another way to do it better in general? This is longer (not to mention demented) but

Re: shortest test for truth false assignment

2002-05-22 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Ronald J Kimball [EMAIL PROTECTED] wrote: if ($a=~tr/.[^0]+/0/c) { do_something(); } Actually, it translates every character that is *not* one of '.[^0]+' into '0'. Which means it does work, with slightly altered true/false semantics than are usual for perl.

Re: perl5.6.1 oddity?

2002-06-14 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], Chris Dolan [EMAIL PROTECTED] wrote: can someone explain why op= does not warn? Is it because (quoting perlop) $a += 2; is equivalent to $a = $a + 2; although without duplicating any side effects that dereferencing the lvalue might trigger and the

Re: Maybe-useful subroutine (BETTER!)

2002-07-01 Thread Yitzchak Scott-Thoennes
Yet Another *::Util Plug: Scalar::Util::reftype finds the underlying type even for objects. (Unfortunately for non-refs it returns undef instead of '' as the builtin ref does.) In article [EMAIL PROTECTED], Abigail [EMAIL PROTECTED] wrote: #!/usr/bin/perl -w use strict; use warnings 'all';

Re: Maybe-useful subroutine (BETTER!)

2002-07-01 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], sara starre [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Yitzchak Scott-Thoennes) wrote: I didn't think that was obfuscated. How about this: sub rotate

Re: Function parameter passing

2002-11-25 Thread Yitzchak Scott-Thoennes
On Mon, 25 Nov 2002 11:34:23 + (GMT), [EMAIL PROTECTED] wrote: $i = 20; my($x, $y, $z) = ($i++, $i, $i++); Now, it appears that perl's evaluation order is accident rather than design - so you SHOULD NOT rely on it. Avoid causing side-effects on variables you use more than once...

Re: Metaprogramming

2002-12-15 Thread Yitzchak Scott-Thoennes
On Sat, 14 Dec 2002 19:09:43 -0500, [EMAIL PROTECTED] wrote: On 14 Dec 2002, at 21:45, Rafael Garcia-Suarez wrote: What do you expect B::Deparse::coderef2text to do here ? Output something equivalent to { 42 + shift } ? or produce an error (can't deparse a closure without complete lexical

Re: Metaprogramming

2002-12-15 Thread Yitzchak Scott-Thoennes
On Sat, 14 Dec 2002 21:09:38 -0800, [EMAIL PROTECTED] wrote: I certainly can't see any point in conditionally giving an error based on where the coderef2text aktescalp e. ^^^ anagram of takes place

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

2003-02-08 Thread Yitzchak Scott-Thoennes
On Sun, 9 Feb 2003 14:34:07 +1100 (EST), [EMAIL PROTECTED] wrote: sub a2 { my $y = ; $y .= $_ . \n for @lines } The = is optional. my $x; $x.=foo intentionally doesn't warn.

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

2003-02-10 Thread Yitzchak Scott-Thoennes
On Mon, 10 Feb 2003 11:09:25 +1100 (EST), [EMAIL PROTECTED] wrote: Yitzchak Scott-Thoennes wrote: Sigh. I'd call that a bug if someone hadn't gone to the trouble to test for it and document it. (Indeed, I see a bug report out there: #6653, was 20010327.008.) So do something like: my @lines

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

2003-02-10 Thread Yitzchak Scott-Thoennes
On Mon, 10 Feb 2003 23:44:14 -0500, [EMAIL PROTECTED] wrote: Yitzchak Scott-Thoennes [EMAIL PROTECTED] wrote: Only if you say $x eq means no lines instead of one empty line missing its \n :) Well, the subject line does say textfile-like, and a 0-byte text file has no lines, not one empty

Re: my if?

2003-07-01 Thread Yitzchak Scott-Thoennes
On Tue, 1 Jul 2003 10:30:34 -0400, [EMAIL PROTECTED] wrote: On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote: my $id = 1 if $_ == 3; This was an accidental feature that is now kept for backwards compatibility, because some programmers have used it to create static

Re: qw(l i s t) vs (l, i, s, t)

2003-07-22 Thread Yitzchak Scott-Thoennes
On Tue, 22 Jul 2003 03:48:53 +0200, [EMAIL PROTECTED] wrote: Could someone please explain what is happening here? I came across it, and had a hard time trying to figure out what was going on. When you use an array in scalar context (e.g. scalar(@ARGV)==foo, or even just @ARGV==foo), it gives

Re: A little arithmetic puzzle

2003-08-14 Thread Yitzchak Scott-Thoennes
On Thu, Aug 14, 2003 at 11:02:19AM +0100, Jonathan E. Paton wrote: Easy, the fastest method is to use stack based notation (RPN). This completely avoids the need for those pesky brackets. The stack is arranged into each of the permutations, and then the operators applied in each permutation.

Re: Comparing items from multiple files

2003-11-20 Thread Yitzchak Scott-Thoennes
On Wed, Nov 19, 2003 at 10:02:34PM -, Peter Scott [EMAIL PROTECTED] wrote: Problem: multiple files containing essentially identical reports which I want to compare. 'diff' isn't the answer; in this case each file contains a bunch of stuff I'm not interested in that can change; I just want

Re: mini-golf: first differing position

2004-04-20 Thread Yitzchak Scott-Thoennes
On Tue, Apr 20, 2004 at 09:59:46PM -0400, Bernie Cosell [EMAIL PROTECTED] wrote: On 20 Apr 2004 at 20:48, Craig S. Cottingham wrote: I couldn't get that to work. Really? I cleaned it up a bit and it seems to work fine: sub diff { my $diff = $_[0] ^ $_[1]; my ($len) = $diff =~

Re: AW: mini-golf: first differing position

2004-04-21 Thread Yitzchak Scott-Thoennes
On Wed, Apr 21, 2004 at 09:44:54AM +0200, Xavier Noria [EMAIL PROTECTED] wrote: Good. With a little modification we get 26 if this is right: $_=$x^$y;$n=$-[0]if/[^\0]/ $x = abc; $y = abc\0\0\0; gives undef instead of the required 3 On Wed, Apr 21, 2004 at 07:48:57AM +0200, Xavier Noria

Re: xor of unicode strings

2004-04-21 Thread Yitzchak Scott-Thoennes
On Wed, Apr 21, 2004 at 07:37:42AM -0700, Yitzchak Scott-Thoennes [EMAIL PROTECTED] wrote: On Wed, 21 Apr 2004, Bernie Cosell wrote: I'm not sure if this is 'fun', but it might be at least curious: I don't have a UTF-8 system handy to try, but I'm wondering: what happens with the string

Re: unhead

2004-09-24 Thread Yitzchak Scott-Thoennes
On Fri, Sep 24, 2004 at 03:17:56PM +0100, Jose Alves de Castro wrote: print if ($N+1)..0; Implicit comparison to $. only happens for constants, so that should be ($. $N) .. 0

Re: P2P in 15 lines

2004-12-16 Thread Yitzchak Scott-Thoennes
On Thu, Dec 16, 2004 at 08:08:11AM -0800, Brad Greenlee wrote: That or someone with sufficient power could make Digest::MD5 or ::SHA1 part of the standard perl distro :-). Digest and Digest::MD5 are in 5.8.0.

Re: Secret operators

2005-02-03 Thread Yitzchak Scott-Thoennes
On Wed, Feb 02, 2005 at 04:20:05PM +0200, Vladi Belperchinov-Shabanski wrote: On Wed, 2 Feb 2005 12:33:35 +1100 (EST) Andrew Savige [EMAIL PROTECTED] wrote: Jos_ Castro wrote: Apart from the secret eskimo greeting and the goatse operator, can anyone tell me about other secret

Re: Unknown level of hash

2005-03-28 Thread Yitzchak Scott-Thoennes
On Mon, Mar 28, 2005 at 03:06:41PM -0800, Zhuang Li wrote: Hi, given an array: @a = ('E1', 'E2', ..., 'En'); Is there an easy way, hopefully one liner, to do the following without a loop? If not, will Perl support this in Perl 6? $hash-{E1}-{E2}-...-{En} = 1; To read from such a series of

Re: Unknown level of hash

2005-03-28 Thread Yitzchak Scott-Thoennes
On Tue, Mar 29, 2005 at 05:50:18AM +, Ton Hospel wrote: I always found the code to do this WITH a loop quite funny in fact: my $work = \$hash; $work = \$$work-{$_} for @a; $$work = 1; Ha ha ha :)

Re: Unknown level of hash

2005-03-29 Thread Yitzchak Scott-Thoennes
On Tue, Mar 29, 2005 at 11:45:01AM +0200, Alexandre Jousset wrote: Yitzchak Scott-Thoennes wrote: To set it, you need to just do the same thing except that at each step instead of keeping the hash element, you keep a reference to it: $entryref = \$hash; $entryref = \$$entryref

Re: Matching at least $x words out of @words

2005-05-06 Thread Yitzchak Scott-Thoennes
On Thu, May 05, 2005 at 09:41:46PM -0400, Rick Delaney wrote: On Fri, May 06, 2005 at 02:05:02AM +0200, A. Pagaltzis wrote: * Jos? Castro [EMAIL PROTECTED] [2005-05-05 16:30]: So suppose you want a regular expression to match at least one of three words: /word1|word2|word3/

Re: Table of Perl 5 Operators

2005-05-18 Thread Yitzchak Scott-Thoennes
On Wed, May 18, 2005 at 10:39:49AM +0100, Jos? Castro wrote: * Michael G Schwern ([EMAIL PROTECTED]) wrote: So... did I miss anything? Should //= be in there? Because my perl 5.8.6 doesn't seem to have it... It's in 5.9.x, or you can add it to 5.8.6 with this patch:

algorithmic challenge

2005-11-17 Thread Yitzchak Scott-Thoennes
This may be of interest to some: Puzzle: The Ham Cheese Sandwich cut. http://perlmonks.org/?node_id=509409

Re: swapping two numbers

2006-06-25 Thread Yitzchak Scott-Thoennes
On Sun, Jun 25, 2006 at 12:31:19AM -0700, Larry Rosler wrote: From: Philippe BooK Bruhat Sent: Saturday, June 24, 2006 04:10 To: fwp@perl.org Subject: Re: swapping two numbers Le vendredi 23 juin 2006 ? 17:40, Samy Kamkar ?crivait: Although x could overflow in this case, where it

date validation via regex

2011-11-15 Thread Yitzchak Scott-Thoennes
This is something people often ask for. The stock answer is that regexes aren't the correct solution, but really it's not so hard. This validates Gregorian MM/DD/CCYY dates, for example: qr#^ (?: 0[1-9] | 1[012] ) / (?: 0[1-9] | 1[0-9] | 2[0-8] | (?! 0[2469]/ | 11/ )

Re: date validation via regex

2011-11-15 Thread Yitzchak Scott-Thoennes
On Tue, Nov 15, 2011 at 11:10 AM, Brian Fraser frase...@gmail.com wrote: No. Just, no. On this list, I think that counts as high praise. Thanks! Read this: http://stackoverflow.com/questions/4077896/perl-or-python-convert-date-from-dd-mm--to--mm-dd/4078817#4078817 Err, which part?

Re: Rate my JAPH

2011-12-07 Thread Yitzchak Scott-Thoennes
Sorry, Randal (initially sent this only to him). On Wed, Dec 7, 2011 at 10:48 AM, Randal L. Schwartz mer...@stonehenge.com wrote: Andrew == Andrew Savige ajsav...@yahoo.com.au writes: Andrew  print Just another Perl hacker, That's missing the trailing semicolon.  I was pretty consistent on

Re: The sperm secret operator: is it new?

2012-03-14 Thread Yitzchak Scott-Thoennes
On Wed, Mar 14, 2012 at 7:48 AM, John Douglas Porter johndpor...@yahoo.com wrote: So is that the Perl 6 smart match operator? or something else? The latter. In any case... How does it work here?  It looks like it's functionally equivalent to scalar()... but why? Perl's ~ is operand

Re: The sperm secret operator: is it new?

2012-03-14 Thread Yitzchak Scott-Thoennes
On Wed, Mar 14, 2012 at 3:50 PM, Philippe Bruhat (BooK) philippe.bru...@free.fr wrote: Frankly, I think this could be considered a bug. Both the left-facing and right-facing versions of the inchworm on a stick should work on all integers in Perl. Complement two arithmetics demand it! Now, the