Re: Perl Christmas Quiz 2009 Answers

2009-12-10 Thread Chris Jack
Leon wrote: Amelia points out that you got her name wrong. She was named by Larry Don't think this gets you off the 1.5 pints you owe me. Chris _ View your other email accounts from your

Perl Christmas Quiz 2009 Answers

2009-12-09 Thread Chris Jack
I thought I should (again) post some sample answers. The challenge of writing a Xmas quiz is always coming up with short, interesting questions that touch on interesting and potentially controversial answers. I spent the better part of a year coming up with the questions I did, and, to be

Re: Perl Christmas Quiz 2009 Answers

2009-12-09 Thread Paul Johnson
On Wed, Dec 09, 2009 at 01:20:54PM +, Chris Jack wrote: I think my answer to question 10 may cause controversy, but it is based on a careful reading of the sited webpage. 10) What is the highest value of X that is a currently available, stable production release of perl 5.X? Answer: 8

Re: Perl Christmas Quiz 2009

2009-12-09 Thread Rallias UberNerd
On Mon, 30 Nov 2009 16:43:19 -0600, Dave Hodgkinson daveh...@gmail.com wrote: On 30 Nov 2009, at 18:24, Chris Jack wrote: Seeing as last year's quiz was mildly popular, Bonus question: How many people will be mildly irritated by starting a new thread with a Reply-to: to an existing one?

Perl Christmas Quiz 2009

2009-12-09 Thread Rallias UberNerd
On Tue, 01 Dec 2009 06:33:49 -0600, David Cantrell da...@cantrell.org.uk wrote: On Mon, Nov 30, 2009 at 10:43:19PM +, Dave Hodgkinson wrote: Bonus question: How many people will be mildly irritated by starting a new thread with a Reply-to: to an existing one? Not as many as will be

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Mike Whitaker
On 1 Dec 2009, at 07:44, Ruud H.G. van Tol wrote: Abigail wrote: On Mon, Nov 30, 2009 at 06:24:12PM +, Chris Jack wrote: 7) Write a one line program that takes a non-negative integer as an argument and prints the square root when the answer's an integer. Restrictions: the perl line

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Philip Newton
On Tue, Dec 1, 2009 at 09:03, Mike Whitaker m...@altrion.org wrote: (this is not an answer) But this might be: echo 169 | perl -pe '/(\d+)(?{ $_ = sqrt($^N).\n })/;' Except it didn't follow the rules. Cheers, Philip -- Philip Newton philip.new...@gmail.com

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Nicholas Clark
On Mon, Nov 30, 2009 at 02:52:21PM -0800, Avleen Vig wrote: On Nov 30, 2009, at 14:43, Dave Hodgkinson daveh...@gmail.com wrote: How many people will be mildly irritated by starting a new thread with a Reply-to: to an existing one? Answer: none. We stopped being petty in 1997 and grew up :p

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Abigail
On Mon, Nov 30, 2009 at 11:40:04PM +, Chris Jack wrote: Abigail abig...@abigail.be wrote On Mon, Nov 30, 2009 at 06:24:12PM +, Chris Jack wrote: 7) Write a one line program that takes a non-negative integer as an argument and prints the square root when the answer's

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Dirk Koopman
Avleen Vig wrote: On Nov 30, 2009, at 14:43, Dave Hodgkinson daveh...@gmail.com wrote: On 30 Nov 2009, at 18:24, Chris Jack wrote: Seeing as last year's quiz was mildly popular, Bonus question: How many people will be mildly irritated by starting a new thread with a Reply-to: to an

Re: Perl Christmas Quiz 2009

2009-12-01 Thread David Cantrell
On Mon, Nov 30, 2009 at 10:43:19PM +, Dave Hodgkinson wrote: Bonus question: How many people will be mildly irritated by starting a new thread with a Reply-to: to an existing one? Not as many as will be mildly irritated at me replying but chopping out the Reply-To. -- David Cantrell |

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Mark Zealey
7) Write a one line program that takes a non-negative integer as an argument and prints the square root when the answer's an integer. Restrictions: the perl line should be a regular expression. You are allowed to use the following functions/operators x, -, length, print plus any of

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Mark Morgan
I recall that as part of technical test I took for a previous role, to try and interpret and determine what it did. Quite cool, but the coolness was definitely exceeded by it's evilness... :) Mark. On Tue, Dec 1, 2009 at 11:26 AM, Abigail abig...@abigail.be wrote: which would be 'similar' but

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Matt Sergeant
On Mon, 30 Nov 2009 18:24:12 +, Chris Jack wrote: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) { $b += 4; } print $a{1} . \n; Bizarrely enough, on both my Snow Leopard machines (default perl

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Matt Sergeant
On Tue, 1 Dec 2009 11:23:09 -0500, Matt Sergeant wrote: On Mon, 30 Nov 2009 18:24:12 +, Chris Jack wrote: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) { $b += 4; } print $a{1} . \n; Bizarrely

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Randal L. Schwartz
Matt == Matt Sergeant mserge...@messagelabs.com writes: Matt On Mon, 30 Nov 2009 18:24:12 +, Chris Jack wrote: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) { $b += 4; } print $a{1} . \n; Matt

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Dermot
2009/12/1 Matt Sergeant mserge...@messagelabs.com: On Tue, 1 Dec 2009 11:23:09 -0500, Matt Sergeant wrote: On Mon, 30 Nov 2009 18:24:12 +, Chris Jack wrote: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) {     $b

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Philip Newton
On Tue, Dec 1, 2009 at 17:52, Dermot paik...@googlemail.com wrote: (not sure about this point) is a copy of the value in $a{1}. That's the salient point - it's an alias to the value in $a{1}, rather than a copy, since values %hash returns aliasses, sort just shuffles those aliasses, and foreach

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Randal L. Schwartz
Dermot == Dermot paik...@googlemail.com writes: Dermot My first impression was that it would be 4. However, without running Dermot it, I would say 0 on the basis that $b is scoped within the loop and Dermot (not sure about this point) is a copy of the value in $a{1}. That's the nice thing

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Dave Cross
On 12/01/2009 04:52 PM, Dermot wrote: 2009/12/1 Matt Sergeantmserge...@messagelabs.com: On Tue, 1 Dec 2009 11:23:09 -0500, Matt Sergeant wrote: On Mon, 30 Nov 2009 18:24:12 +, Chris Jack wrote: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0);

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Dermot
2009/12/1 Philip Newton philip.new...@gmail.com: On Tue, Dec 1, 2009 at 17:52, Dermot paik...@googlemail.com wrote: (not sure about this point) is a copy of the value in $a{1}. That's the salient point - it's an alias to the value in $a{1}, rather than a copy, since values %hash returns

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Randal L. Schwartz
Matt == Matt Sergeant mserge...@messagelabs.com writes: Matt Yes. Though oddly enough it doesn't show up in the same terminal when Matt ssh'd into a Linux box. I'd like to know the reason why that is. Maybe linux doesn't echo the ^D as uparrow D? Or maybe linux adds a newline after it? Dunno.

Re: Perl Christmas Quiz 2009

2009-12-01 Thread Matt Sergeant
On Tue, 01 Dec 2009 08:47:55 -0800, Randal L. Schwartz wrote: Lemme guess. You did this: $ perl ... type program in here ... ^D (control D) The D is from your control D. Common misconception. Yes. Though oddly enough it doesn't show up in the same terminal when ssh'd into a Linux

Perl Christmas Quiz 2009

2009-11-30 Thread Chris Jack
Seeing as last year's quiz was mildly popular, I thought I'd do another one. I've changed the mix of questions based on what people submitted answers to last year - it also arguably a little more educational this time around. Any feedback about the quiz, either private or public is welcome.

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Simon Wistow
On Mon, Nov 30, 2009 at 06:24:12PM +, Chris Jack said: 6) What is the name of the official Soft Toy Camel of the London Perl Mongers? Bonus mark if you own one. I bet only 2 people get this correct although I suspect several people will get the answer the OP was thinking of.

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Dave Cross
On 30/11/09 18:24, Chris Jack wrote: In-Reply-To: mailman.10014.1258641251.36522.london...@london.pm.org References: mailman.10014.1258641251.36522.london...@london.pm.org Grrr 1) Without running it to check, what does the following program output? my %a = (3,2,1,0);

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Simon Wistow
On Mon, Nov 30, 2009 at 07:38:31PM +, Dave Cross said: According to the Beanie Baby people, he's called Niles. According to us (and the 2001 leadership election ballot papers) she's called Amelia. [ SPOILER SPACE ] Actually - there are two

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Randal L. Schwartz
Dave == Dave Cross d...@dave.org.uk writes: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) { $b += 4; } print $a{1} . \n; Dave Without running it, I'd say 4. Having now run it, I'm glad that's what I said

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Paul Johnson
On Mon, Nov 30, 2009 at 12:14:21PM -0800, Randal L. Schwartz wrote: Dave == Dave Cross d...@dave.org.uk writes: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) { $b += 4; } print $a{1} . \n;

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Abigail
On Mon, Nov 30, 2009 at 06:24:12PM +, Chris Jack wrote: Seeing as last year's quiz was mildly popular, I thought I'd do another one. I've changed the mix of questions based on what people submitted answers to last year - it also arguably a little more educational this time around. Any

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Graham Barr
On Nov 30, 2009, at 3:17 PM, Graham Barr wrote: On Nov 30, 2009, at 2:14 PM, Randal L. Schwartz wrote: Dave == Dave Cross d...@dave.org.uk writes: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) { $b += 4;

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Graham Barr
On Nov 30, 2009, at 2:14 PM, Randal L. Schwartz wrote: Dave == Dave Cross d...@dave.org.uk writes: 1) Without running it to check, what does the following program output? my %a = (3,2,1,0); for my $b (sort values %a) { $b += 4; } print $a{1} . \n; Dave Without running it,

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Abigail
On Mon, Nov 30, 2009 at 03:22:04PM -0600, Graham Barr wrote: On Nov 30, 2009, at 3:17 PM, Graham Barr wrote: On Nov 30, 2009, at 2:14 PM, Randal L. Schwartz wrote: Dave == Dave Cross d...@dave.org.uk writes: 1) Without running it to check, what does the following program

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Martin A. Brooks
Merry Ex-Mass. A sysadmin and pedant's point of view On 30/11/2009 18:24, Chris Jack wrote: 1) Without running it to check, what does the following program output? Something like: bash: syntax error near unexpected token '(' Don't assume my default interpreter is your default

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Randal L. Schwartz
Graham == Graham Barr gb...@pobox.com writes: Graham I meant to add that this change to sort was added to 5.6.0. So to Graham answer your question it was nearly a decade ago :-) Yeah, well it wasn't true when I was running Perl 2.0 on the One True Unix under the Real Bourne Shell :-) --

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Dave Hodgkinson
On 30 Nov 2009, at 18:24, Chris Jack wrote: Seeing as last year's quiz was mildly popular, Bonus question: How many people will be mildly irritated by starting a new thread with a Reply-to: to an existing one? -- Dave HodgkinsonMSN: daveh...@hotmail.com

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Avleen Vig
On Nov 30, 2009, at 14:43, Dave Hodgkinson daveh...@gmail.com wrote: On 30 Nov 2009, at 18:24, Chris Jack wrote: Seeing as last year's quiz was mildly popular, Bonus question: How many people will be mildly irritated by starting a new thread with a Reply-to: to an existing one? Answer:

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Roger Burton West
On Mon, Nov 30, 2009 at 10:43:19PM +, Dave Hodgkinson wrote: How many people will be mildly irritated by starting a new thread with a Reply-to: to an existing one? Meh, judging by the headers he's probably never used a threaded email client so has no reason to know any better. No point in

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Ask Bjørn Hansen
On Nov 30, 2009, at 13:21, Martin A. Brooks wrote: A sysadmin and pedant's point of view I take it sysadmins are too angry and bitter to understand or care for the holiday[1] spirit I'm sure the quiz was sent in. Why don't you go change someones password? - ask [1]

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Graham Barr
On Nov 30, 2009, at 3:51 PM, Abigail wrote: I meant to add that this change to sort was added to 5.6.0. So to answer your question it was nearly a decade ago :-) Which was the same release where values() returned aliases instead of copies. Ah, you are right. sort was before that. the

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Chris Jack
Abigail abig...@abigail.be wrote On Mon, Nov 30, 2009 at 06:24:12PM +, Chris Jack wrote: 7) Write a one line program that takes a non-negative integer as an argument and prints the square root when the answer's an integer. Restrictions: the perl line should be a regular

Re: Perl Christmas Quiz 2009

2009-11-30 Thread James Coupe
Chris Jack chris_j...@msn.com wrote: Abigail abig...@abigail.be wrote On Mon, Nov 30, 2009 at 06:24:12PM +, Chris Jack wrote: 7) Write a one line program that takes a non-negative integer as an argument and prints the square root when the answer's an integer. Restrictions: the perl

Re: Perl Christmas Quiz 2009

2009-11-30 Thread James Coupe
James Coupe ja...@zephyr.org.uk wrote: $ perl -e '(1 x $ARGV[0]) =~ m/^(1*)((??{$1x(length($1)-1)})$)(?(2)(?{print length $1}))/' 4 2 I don't recommend trying it on large numbers. 1024 was about as high as my boredom threshold could tolerate on this box. Oh, it gets better if I do something

Re: Perl Christmas Quiz 2009

2009-11-30 Thread Ruud H.G. van Tol
Abigail wrote: On Mon, Nov 30, 2009 at 06:24:12PM +, Chris Jack wrote: 7) Write a one line program that takes a non-negative integer as an argument and prints the square root when the answer's an integer. Restrictions: the perl line should be a regular expression. Just a regular