Re: [Gllug-Social] [ANNOUNCE] London.pm December social 2009-12-03, The Prince Bonaparte, W2 5BE
On Sun, Nov 29, 2009 at 04:58:06PM +, Edmund von der Burg wrote: 2009/11/28 Mark Fowler m...@twoshortplanks.com: Pub socials start essentially after people are done with work. For those who are CFT enabled the social essentially starts with the dim sum lunch, followed by some sort of attempt to churn out a few hours 'work' at either the restaurant, the pub or somewhere conveniently en-route between the two. Cheers, Edmund. CFT: 'copious free time' aka 'between jobs' aka 'must stay off IRC when drunk' A now I know where I've been going wrong . Thanks. L.
Perl Christmas Quiz 2009
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. Apologies if any of it doesn't come out well formatted - it all looked fine before I hit send. 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; 2) If you received a perl mongers award for contributions to the Perl community, what colour/type of camel would the award be? 3) What is Perl XS? What does XS stand for? 4) Based on your answer to the previous question, what do you conclude about Perl programmers spelling ability? 5) Write a short perl program that has a memory leak. Bonus mark for one line solutions. Second bonus mark for the shortest program. 6) What is the name of the official Soft Toy Camel of the London Perl Mongers? Bonus mark if you own one. 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 the usual regular expression bestiary. Hint: Consider converting the number to unary. 8) According to amazon.co.uk, what is the best selling Perl book so far in 2009? 9) What is the youtube.com link for the perl v other languages videos discussed on this list, and also the bubble sort video? 10) What is the highest value of X that is a currently available, stable production release of perl 5.X? 11) Think of a witty and/or interesting Perl Christmas quiz question and answer it. _ Have more than one Hotmail account? Link them together to easily access both http://clk.atdmt.com/UKM/go/186394591/direct/01/
Re: Perl Christmas Quiz 2009
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
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); for my $b (sort values %a) { $b += 4; } print $a{1} . \n; Without running it, I'd say 4. Having now run it, I'm glad that's what I said :) 2) If you received a perl mongers award for contributions to the Perl community, what colour/type of camel would the award be? There are quite a few people on this list who have insider knowledge here. 3) What is Perl XS? What does XS stand for? It doesn't _stand_ for anything. It's short for XSUB which, in turn, is short for (I'm guessing) eXternal SUBroutine. 4) Based on your answer to the previous question, what do you conclude about Perl programmers spelling ability? I think this leads to theories about perl programmers' spelling abilities, rather than Perl programmers' spelling abilities. There's an important difference. 5) Write a short perl program that has a memory leak. Bonus mark for one line solutions. Second bonus mark for the shortest program. Sorry but it's a matter of professional pride that I _never_ write code with memory leaks - honest! 6) What is the name of the official Soft Toy Camel of the London Perl Mongers? Bonus mark if you own one. According to the Beanie Baby people, he's called Niles. According to us (and the 2001 leadership election ballot papers) she's called Amelia. 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 the usual regular expression bestiary. Hint: Consider converting the number to unary. I'll leave that to the golfing experts. 8) According to amazon.co.uk, what is the best selling Perl book so far in 2009? Does Amazon give an annual sales chart? I thought they just showed a current sales chart. Current top of that chart is the Perl Template Toolkit book (or, rather, it will be once you've all bought copies as christmas presents for all your friends and family). 9) What is the youtube.com link for the perl v other languages videos discussed on this list, and also the bubble sort video? I must have missed those discussions. 10) What is the highest value of X that is a currently available, stable production release of perl 5.X? 10.1 11) Think of a witty and/or interesting Perl Christmas quiz question and answer it. What was the most embarrassing Perl web site launch of 2009? blogs.perl.org! Cheers, Dave...
Re: Perl Christmas Quiz 2009
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 stuffed camels. Amelia belonged to Leon (as much as you own a camel for they are like Patek Phillipe watches, you merely look after it until the next generation. Or until you stuff it with a sheep stuffed with chickens stuff with fish stuffed with eggs) and ran for election. Niles was passed down amongst leaders - I know that Mark passed it to me and I passed it to Greg. Unless Greg behaved in an untoward manner towards the poor beast (and lets face it he has, as they say in the world of Policing, previous form) he should have passed him to Leon.
Re: Perl Christmas Quiz 2009
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 Dave :) When did sort start returning lvalues? I bet if you did this on an older Perl, it'd return 0. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
Re: Perl Christmas Quiz 2009
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; Dave Without running it, I'd say 4. Having now run it, I'm glad that's what I said Dave :) When did sort start returning lvalues? I bet if you did this on an older Perl, it'd return 0. But you couldn't use too old a perl or it would get upset by the for my. So probably 5.4.x or so would be the ticket. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net
Re: Perl Christmas Quiz 2009
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 feedback about the quiz, either private or public is welcome. Apologies if any of it doesn't come out well formatted - it all looked fine before I hit send. 5) Write a short perl program that has a memory leak. Bonus mark for one line solutions. Second bonus mark for the shortest program. valgrind claims the shortest possible perl program leaks 5 bytes: $ valgrind perl -e'' [] ==19803== LEAK SUMMARY: ==19803==definitely lost: 5 bytes in 1 blocks. ==19803== possibly lost: 0 bytes in 0 blocks. ==19803==still reachable: 82919 bytes in 623 blocks. ==19803== suppressed: 0 bytes in 0 blocks. 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 expression? Regular expressions don't print, so that would be impossible. You are allowed to use the following functions/operators x, -, length, print plus any of the usual regular expression bestiary. Hint: Consider converting the number to unary. Perhaps you want a regular expression that determines whether a number a prime. I think that's either trivial, or impossible, depending on the restriction. If we may use (?{ })/(??{ }), it's trivial, because that means we can do any you can do in ordinary Perl. With being allowed to execute Perl code, I do not think it to be possible - I've been trying to achieve that on and off for years. Even if with (named) rules, I believe it to be impossible. AFAIK, the set of all strings of a unary alphabet whose length is a square cannot be recognized by a PDA - and I don't think backreferences are powerful enough to bridge this gap. Of course, one could cheat and write a regular expression that just lists all the square numbers 1 .. MAX_INT. But I don't think that's the solution you're after. 10) What is the highest value of X that is a currently available, stable production release of perl 5.X? According to perlhist, that would be X = 001m: 5.001m is the most recent perl it claims to be 'stable' or 'very stable'. Abigail
Re: Perl Christmas Quiz 2009
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; } print $a{1} . \n; Dave Without running it, I'd say 4. Having now run it, I'm glad that's what I said Dave :) When did sort start returning lvalues? I bet if you did this on an older Perl, it'd return 0. sort just shuffles whatever SV* are on the stack, and values returns aliases, so in this case you end up with aliases being returned by sort. 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 :-) Graham.
Re: Perl Christmas Quiz 2009
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, I'd say 4. Having now run it, I'm glad that's what I said Dave :) When did sort start returning lvalues? I bet if you did this on an older Perl, it'd return 0. sort just shuffles whatever SV* are on the stack, and values returns aliases, so in this case you end up with aliases being returned by sort. Graham.
Re: Perl Christmas Quiz 2009
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 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 Dave :) When did sort start returning lvalues? I bet if you did this on an older Perl, it'd return 0. sort just shuffles whatever SV* are on the stack, and values returns aliases, so in this case you end up with aliases being returned by sort. 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. Abigail
Re: Perl Christmas Quiz 2009
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 interpreter. 2) If you received a perl mongers award for contributions to the Perl community, what colour/type of camel would the award be? One that knew where to use an apostrophe. 3) What is Perl XS? What does XS stand for? Assuming infinite CPU power, infinite memory, infinite disk space and infinite bandwidth, writing a shopping cart... 4) Based on your answer to the previous question, what do you conclude about Perl programmers spelling ability? There's not enough oleum in the world. 5) Write a short perl program that has a memory leak. Bonus mark for one line solutions. Second bonus mark for the shortest program. See infinite memory above. 6) What is the name of the official Soft Toy Camel of the London Perl Mongers? Bonus mark if you own one. richardc. 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. No. Write a program that isn't crammed with FAIL, and isn't a pain in the arse to roll out and maintain. Go on, we sysadmins dare you. 8) According to amazon.co.uk, what is the best selling Perl book so far in 2009? According to the ticket queue, I'd say Perl for dummies in 7 days or less. 9) What is the youtube.com link for the perl v other languages videos discussed on this list, and also the bubble sort video? http://www.youtube.com/watch?v=3jDfSqtG2E4 10) What is the highest value of X that is a currently available, stable production release of perl 5.X? 5.10.0-19lenny2 duh. 11) Think of a witty and/or interesting Perl Christmas quiz question and answer it. ...and here are 10 reasons why I can justify my salary
Re: Perl Christmas Quiz 2009
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 :-) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
Re: Perl Christmas Quiz 2009
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 Site: http://www.davehodgkinson.com UK: +44 7768 490620 Blog: http://www.davehodgkinson.com/blog Photos: http://www.flickr.com/photos/davehodg
Re: Perl Christmas Quiz 2009
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: none. We stopped being petty in 1997 and grew up :p
Re: Perl Christmas Quiz 2009
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 mocking the afflicted. Just hit #... Roger
Re: Perl Christmas Quiz 2009
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] http://xrl.us/holidays
Re: Perl Christmas Quiz 2009
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 oldest perl I have is 5.4.5 which gives $ /apps/perl-5.4.5/bin/perl5.00405 -l my @a = (4,3,2,1); for my $x (sort @a) { print ++$x; } print @a; __END__ 2 3 4 5 5432 Graham.
Re: Perl Christmas Quiz 2009
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 expression. Just a regular expression? Regular expressions don't print, so that would be impossible. Pedant. Perl regular expressions allow execution of arbitrary code blocks - which is why I put restrictions on which ordinary functions you were allowed to use. The actual square root algorithm, however, should only use the normal regular expression bestiary. I was going to point you towards my talk on Perl one-liners - which shows the basic idea behind prime number checking and solving linear equations - but I can't find any of the talks on the London Perl Mongers website... The principal behind doing square root is similar but different. As far as I'm aware, no-one has published this previously - so you can claim bragging rights if you do it before I give my solution. _ Use Hotmail to send and receive mail from your different email accounts http://clk.atdmt.com/UKM/go/186394592/direct/01/
Re: Perl Christmas Quiz 2009
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 line should be a regular expression. Just a regular expression? Regular expressions don't print, so that would be impossible. Pedant. Perl regular expressions allow execution of arbitrary code blocks - which is why I put restrictions on which ordinary functions you were allowed to use. The actual square root algorithm, however, should only use the normal regular expression bestiary. It's not obvious to me what you're regarding as ordinary and normal, but I get something like... $ 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. -- James Coupe
Re: Perl Christmas Quiz 2009
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 _sensible_ and make the (1*) non-greedy - so (1*?). Duh. -- James Coupe
Re: Perl Christmas Quiz 2009
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 expression? Regular expressions don't print, so that would be impossible. Though perl can print itself: echo 169 | perl -ple'$_=the square rootif/^\d+$/' (this is not an answer) -- Ruud