From rory at employees.org Tue Feb 14 23:25:42 2006 From: rory at employees.org (Rory Macdonald) Date: Wed, 15 Feb 2006 07:25:42 +0000 Subject: [Edinburgh-pm] February meeting reminder Message-ID: <1139988342.26606.1.camel@localhost.localdomain> Hi, Just a reminder that tonight is the February social meeting, 7:30pm at Guildford Arms. Rory From perl at aaroncrane.co.uk Wed Feb 15 10:33:54 2006 From: perl at aaroncrane.co.uk (Aaron Crane) Date: Wed, 15 Feb 2006 18:33:54 +0000 Subject: [Edinburgh-pm] February meeting reminder In-Reply-To: <1139988342.26606.1.camel@localhost.localdomain> References: <1139988342.26606.1.camel@localhost.localdomain> Message-ID: <20060215183354.GB3509@aaroncrane.co.uk> Rory Macdonald writes: > Just a reminder that tonight is the February social meeting, 7:30pm at > Guildford Arms. Rats -- I forgot about the meeting, and I have to be elsewhere tonight. See you all next month, I hope. Here's a thing, though. Isn't our normal meeting date the second Wednesday of the month? And isn't the 15th actually the third Wednesday? If my calculations are correct, that'll also apply in March as well... -- Aaron Crane From robrwo at gmail.com Wed Feb 15 12:39:32 2006 From: robrwo at gmail.com (Robert Rothenberg) Date: Wed, 15 Feb 2006 20:39:32 +0000 Subject: [Edinburgh-pm] February meeting reminder In-Reply-To: <20060215183354.GB3509@aaroncrane.co.uk> References: <1139988342.26606.1.camel@localhost.localdomain> <20060215183354.GB3509@aaroncrane.co.uk> Message-ID: <43F39184.6060305@gmail.com> On 02/15/2006 06:33 PM Aaron Crane wrote: > Rory Macdonald writes: >> Just a reminder that tonight is the February social meeting, 7:30pm at >> Guildford Arms. > > Rats -- I forgot about the meeting, and I have to be elsewhere tonight. > See you all next month, I hope. > > Here's a thing, though. Isn't our normal meeting date the second > Wednesday of the month? And isn't the 15th actually the third > Wednesday? If my calculations are correct, that'll also apply in March > as well... Yes, I thought it was last week too (which I was unable to make it to). Don't think I;ll be able to make it tonight, and next month I've got things to do on the 8th. Speaking of future meetings, I heard from a while back Barbie that some of the Birmingham.pm folk may make a field trip to Edinburgh for the April meet. Rob From asmith9983 at gmail.com Wed Feb 15 15:31:41 2006 From: asmith9983 at gmail.com (asmith9983@gmail.com) Date: Wed, 15 Feb 2006 23:31:41 +0000 (GMT) Subject: [Edinburgh-pm] meeting reminders In-Reply-To: <43F39184.6060305@gmail.com> References: <1139988342.26606.1.camel@localhost.localdomain> <20060215183354.GB3509@aaroncrane.co.uk> <43F39184.6060305@gmail.com> Message-ID: Hi guys I went along last week since it was the second Wednesday in the month, but only stayed for 30 minutes as nobody else turned up. I think we should have a little competition to write the best one-liner perl script to run in a crontab to send a meeting reminder to the list on the preceding Saturday. Assume it will run on a Linux system. -- Andrew On Wed, 15 Feb 2006, Robert Rothenberg wrote: > >On 02/15/2006 06:33 PM Aaron Crane wrote: >> Rory Macdonald writes: >>> Just a reminder that tonight is the February social meeting, 7:30pm at >>> Guildford Arms. >> >> Rats -- I forgot about the meeting, and I have to be elsewhere tonight. >> See you all next month, I hope. >> >> Here's a thing, though. Isn't our normal meeting date the second >> Wednesday of the month? And isn't the 15th actually the third >> Wednesday? If my calculations are correct, that'll also apply in March >> as well... > >Yes, I thought it was last week too (which I was unable to make it to). >Don't think I;ll be able to make it tonight, and next month I've got things >to do on the 8th. > >Speaking of future meetings, I heard from a while back Barbie that some of >the Birmingham.pm folk may make a field trip to Edinburgh for the April meet. > >Rob >_______________________________________________ >Edinburgh-pm mailing list >Edinburgh-pm at pm.org >http://mail.pm.org/mailman/listinfo/edinburgh-pm > From perl at minty.org Thu Feb 16 00:24:30 2006 From: perl at minty.org (Murray) Date: Thu, 16 Feb 2006 08:24:30 +0000 Subject: [Edinburgh-pm] February meeting reminder In-Reply-To: <43F39184.6060305@gmail.com> References: <1139988342.26606.1.camel@localhost.localdomain> <20060215183354.GB3509@aaroncrane.co.uk> <43F39184.6060305@gmail.com> Message-ID: <20060216082430.GA836@minty.org> On Wed, Feb 15, 2006 at 08:39:32PM +0000, Robert Rothenberg wrote: > Speaking of future meetings, I heard from a while back Barbie that some of > the Birmingham.pm folk may make a field trip to Edinburgh for the April meet. I should be in Edinburgh for the April meet, so that would work out perfectly! From rory at employees.org Thu Feb 16 00:31:44 2006 From: rory at employees.org (Rory Macdonald) Date: Thu, 16 Feb 2006 08:31:44 +0000 Subject: [Edinburgh-pm] February meeting reminder In-Reply-To: <20060215183354.GB3509@aaroncrane.co.uk> References: <1139988342.26606.1.camel@localhost.localdomain> <20060215183354.GB3509@aaroncrane.co.uk> Message-ID: <1140078704.1826.4.camel@localhost.localdomain> On Wed, 2006-02-15 at 18:33 +0000, Aaron Crane wrote: > Rory Macdonald writes: > > Just a reminder that tonight is the February social meeting, 7:30pm at > > Guildford Arms. > > Rats -- I forgot about the meeting, and I have to be elsewhere tonight. > See you all next month, I hope. > > Here's a thing, though. Isn't our normal meeting date the second > Wednesday of the month? And isn't the 15th actually the third > Wednesday? If my calculations are correct, that'll also apply in March > as well... Hangs head in shame. Sorry everyone. Rory From barbie at missbarbell.co.uk Thu Feb 16 03:58:55 2006 From: barbie at missbarbell.co.uk (Barbie) Date: Thu, 16 Feb 2006 11:58:55 +0000 Subject: [Edinburgh-pm] February meeting reminder In-Reply-To: <43F39184.6060305@gmail.com> References: <1139988342.26606.1.camel@localhost.localdomain> <20060215183354.GB3509@aaroncrane.co.uk> <43F39184.6060305@gmail.com> Message-ID: <20060216115855.GC5208@smtp.blueyonder.co.uk> On Wed, Feb 15, 2006 at 08:39:32PM +0000, Robert Rothenberg wrote: > > Speaking of future meetings, I heard from a while back Barbie that some of > the Birmingham.pm folk may make a field trip to Edinburgh for the April meet. We will indeed be paying you guys a visit. April 12th, as part of our World Tour of UK Perl Mongers user groups. At the moment JJ and myself have booked flights, and will be heading up on the Wednesday and departing on Thursday morning. There are a few other interested parties, but no-one else has committed to booking flights yet. Incidentally, can anyone recommend a hotel for us to book into? Preferably not too far from the social meeting venue so we can at least stagger back :) Cheers, Barbie. PS: The World Tour bit comes from me being a fan of Billy Connolly :) From perl at minty.org Thu Feb 16 04:57:19 2006 From: perl at minty.org (Murray) Date: Thu, 16 Feb 2006 12:57:19 +0000 Subject: [Edinburgh-pm] meeting reminders In-Reply-To: References: <1139988342.26606.1.camel@localhost.localdomain> <20060215183354.GB3509@aaroncrane.co.uk> <43F39184.6060305@gmail.com> Message-ID: <20060216125718.GA13757@jess.minty.org> On Wed, Feb 15, 2006 at 11:31:41PM +0000, asmith9983 at gmail.com wrote: > I think we should have a little competition to write the best one-liner perl > script to run in a crontab to send a meeting reminder to the list on the > preceding Saturday. Assume it will run on a Linux system. Okay, I'll bite with a starter for 10. I forget the rules, modules allowed? Mailing via exim okay [1] ? 15 9 * * 6 perl -e 'use Date::Manip;$t="2006-04-8";@d=ParseRecur( \ "0:1*2:3:0:0:0","2006-01-11",$t,DateCalc($t,"+ 1 month")); \ if (Date_Cmp($d[0],DateCalc($t,"+ 4 days"))==0){print( \ "Whiskey Wednesday!\n");}'|exim edinburgh-pm at pm.org [1] Assuming the sender is subscribed to the list... From perl at minty.org Thu Feb 16 05:01:52 2006 From: perl at minty.org (Murray) Date: Thu, 16 Feb 2006 13:01:52 +0000 Subject: [Edinburgh-pm] meeting reminders Message-ID: <20060216130152.GC13757@jess.minty.org> ahem... 15 9 * * 6 perl -e 'use Date::Manip;$t="today";@d=ParseRecur( \ "0:1*2:3:0:0:0","2006-02-08",$t,DateCalc($t,"+ 1 month")); \ if (Date_Cmp($d[0],DateCalc($t,"+ 4 days"))==0){print( \ "Whiskey Wednesday!\n");}'|exim edinburgh-pm at pm.org From robinv at gmail.com Thu Feb 16 07:25:03 2006 From: robinv at gmail.com (Robin Vickery) Date: Thu, 16 Feb 2006 15:25:03 +0000 Subject: [Edinburgh-pm] meeting reminders In-Reply-To: <20060216130152.GC13757@jess.minty.org> References: <20060216130152.GC13757@jess.minty.org> Message-ID: <5cb2dafd0602160725yfc01decme7127171e7edb42b@mail.gmail.com> On 2/16/06, Murray wrote: > ahem... > > 15 9 * * 6 perl -e 'use Date::Manip;$t="today";@d=ParseRecur( \ > "0:1*2:3:0:0:0","2006-02-08",$t,DateCalc($t,"+ 1 month")); \ > if (Date_Cmp($d[0],DateCalc($t,"+ 4 days"))==0){print( \ > "Whiskey Wednesday!\n");}'|exim edinburgh-pm at pm.org How about this? 15 9 * * 6 perl -e '$d=(localtime(time+345600))[3]; print "Drink on Wednesday?" if $d>7 && $d<15;' \ | mail -es "Monthly Social" edinburgh-pm at pm.org Hello, by the way. I've only just joined the list. -robin From perl at aaroncrane.co.uk Thu Feb 16 07:26:13 2006 From: perl at aaroncrane.co.uk (Aaron Crane) Date: Thu, 16 Feb 2006 15:26:13 +0000 Subject: [Edinburgh-pm] meeting reminders In-Reply-To: <20060216130152.GC13757@jess.minty.org> References: <20060216130152.GC13757@jess.minty.org> Message-ID: <20060216152612.GF3509@aaroncrane.co.uk> Murray writes: > 15 9 * * 6 perl -e 'use Date::Manip;$t="today";@d=ParseRecur( \ > "0:1*2:3:0:0:0","2006-02-08",$t,DateCalc($t,"+ 1 month")); \ > if (Date_Cmp($d[0],DateCalc($t,"+ 4 days"))==0){print( \ > "Whiskey Wednesday!\n");}'|exim edinburgh-pm at pm.org Did someone say "one-liner"? Well, I always find it hard to resist a golf challenge.[1] This version saves a lot of code by precalculating most of the date arithmetic at programming time: 15 9 4-10 * * perl -e'exit 1if(localtime)[6]!=6'&&echo Whiskey Wednesday!|exim edinburgh-pm at pm.org The trick there is that we can easily determine that the Saturday before the second Wednesday of the month is never earlier than the 4th or later than the 10th, so we can persuade cron to handle the range test for an expenditure of only 3 strokes ("4-10" instead of "*"), while removing all the code that calculates the date of the Saturday before the second Wednesday. Then the only thing to do is check whether today is a Saturday. I think that's by far the most interesting thing I've come up with; the rest is just golfing. For example, we can save 4 strokes with an algebraic identity: 15 9 4-10 * * perl -e'exit 6-(localtime)[6]'&&echo Whiskey Wednesday!|exim edinburgh-pm at pm.org And 2 further strokes by abusing the backtick operator: 15 9 4-10 * * perl -e'6-(localtime)[6]||`echo Whiskey Wednesday!|exim edinburgh-pm\@pm.org`' And, of course, we can save 3 strokes from any of the preceding ones if we assume that local time is always close enough to UTC: 15 9 4-10 * * perl -e'6-(gmtime)[6]||`echo Whiskey Wednesday!|exim edinburgh-pm\@pm.org`' Finally, we might as well save an extra stroke for the time of day we send the message: 9 9 4-10 * * perl -e'6-(gmtime)[6]||`echo Whiskey Wednesday!|exim edinburgh-pm\@pm.org`' Here's an even shorter non-Perl solution: 9 9 4-10 * * date +%w|grep -q 6&&echo Whiskey Wednesday!|exim edinburgh-pm at pm.org Were it not for Cron's carefully-designed but, sadly, broken behaviour of OR-ing the day-of-week and day-of-month specifications together, you could do this, which seems much neater to me, not to mention substantially shorter: 9 9 4-10 * 6 echo Whiskey Wednesday!|exim edinburgh-pm at pm.org [1] Yes, I do know that the original suggestion was to come up with the best one-liner, not the shortest implementation. But, hey, golf can be fun anyway, right? -- Aaron Crane From asmith9983 at gmail.com Sat Feb 18 02:42:48 2006 From: asmith9983 at gmail.com (asmith9983@gmail.com) Date: Sat, 18 Feb 2006 10:42:48 +0000 (GMT) Subject: [Edinburgh-pm] A little perl help please Message-ID: Hi guys I want this little perl one-liner to run without assigning the return of gmtime to an array. Is this possible ? Soomething like this but as this doesn't work,not this perl -e -w 'use strict "vars";print "Today is Friday" if (gmtime[6] == 5);' I was hoping to keep the code short. Thanks. -- Andrew From perl at aaroncrane.co.uk Sat Feb 18 03:30:56 2006 From: perl at aaroncrane.co.uk (Aaron Crane) Date: Sat, 18 Feb 2006 11:30:56 +0000 Subject: [Edinburgh-pm] A little perl help please In-Reply-To: References: Message-ID: <20060218113055.GA11308@aaroncrane.co.uk> asmith9983 at gmail.com writes: > I want this little perl one-liner to run without assigning the return > of gmtime to an array. Is this possible? Soomething like this but as > this doesn't work, not this > perl -e -w 'use strict "vars";print "Today is Friday" if (gmtime[6] == 5);' The slightly-confusing thing here is that there are multiple things that use square-bracket syntax. You're looking for array subscripting, as in this code: my @x = gmtime; print "..." if $x[6] == 5; However, Perl only lets you do that directly if you have an actual array variable (something that could take an '@' sigil). In this case, you've got print "..." if gmtime[6] == 5; which Perl treats as if it were print "..." if gmtime([6]) == 5; That is, you're calling gmtime() with a single argument: a reference to an anonymous array containing the value 6. Since array subscripting isn't available when you don't have an actual array variable, the alternative is to use a list slice. List slices look very much like array subscripts, but since there's no sigil, they need an extra set of parentheses round the list being sliced: print "..." if (gmtime)[6] == 5; A handy tip for helping to debug things like this: the B::Deparse module can deparse the internal compiled form of your code back to source. For various reasons, you don't invoke B::Deparse directly, but through the O.pm module instead. Using it normally looks like this: perl -MO=Deparse -e '...' or perl -MO=Deparse file.pl B::Deparse also has a -p option, which adds excess parentheses to reveal the precedence in your code. Running your original code and the fixed version using Deparse -p looks like this: $ perl -MO=Deparse,-p -e 'print "Today is Friday" if gmtime[6] == 5' ((gmtime([6]) == 6) and print('Today is Friday')); -e syntax OK $ perl -MO=Deparse,-p -e 'print "Today is Friday" if (gmtime)[6] == 5' (((gmtime)[6] == 6) and print('Today is Friday')); -e syntax OK The first of those makes it clear that gmtime is being called with an argument. -- Aaron Crane From nick at vallianos.org Sat Feb 18 13:11:34 2006 From: nick at vallianos.org (Nick Vallianos) Date: Sat, 18 Feb 2006 22:11:34 +0100 (CET) Subject: [Edinburgh-pm] A little perl help please In-Reply-To: <20060218113055.GA11308@aaroncrane.co.uk> References: <20060218113055.GA11308@aaroncrane.co.uk> Message-ID: <28339.217.43.58.252.1140297094.squirrel@217.43.58.252> try gmtime()[6] (not sure it works, just an idea) From chrisb at jesmond.demon.co.uk Sat Feb 18 13:57:54 2006 From: chrisb at jesmond.demon.co.uk (Chris Benson) Date: Sat, 18 Feb 2006 21:57:54 +0000 Subject: [Edinburgh-pm] A little perl help please In-Reply-To: References: Message-ID: <20060218215754.A10883@gamma.home> On Sat, Feb 18, 2006 at 10:42:48AM +0000, asmith9983 at gmail.com wrote: > Hi guys > > I want this little perl one-liner to run without assigning the return of gmtime > to an array. Is this possible ? > Soomething like this but as this doesn't work,not this > perl -e -w 'use strict "vars";print "Today is Friday" if (gmtime[6] == 5);' And make sure that the code to evaluate is immediately after the -e. In the above example, Perl will evaluate -w perl -lwe 'print "Friday" if 5 == (gmtime)[6]' -- Chris Benson From eric.robertson at blueyonder.co.uk Sun Feb 19 06:36:57 2006 From: eric.robertson at blueyonder.co.uk (Eric Robertson) Date: Sun, 19 Feb 2006 14:36:57 -0000 Subject: [Edinburgh-pm] A little perl help please In-Reply-To: <20060218215754.A10883@gamma.home> Message-ID: <002601c63561$eff887e0$0300a8c0@Time> On Saturday, February 18, 2006 9:58 PM Chris Benson wrote: >And make sure that the code to evaluate is immediately after the -e. >In the above example, Perl will evaluate -w >perl -lwe 'print "Friday" if 5 == (gmtime)[6]' And for those trying this on Windows: perl -lwe "print q(Friday) if 5 == (gmtime)[6]" Eric Robertson _______________________________________________ Edinburgh-pm mailing list Edinburgh-pm at pm.org http://mail.pm.org/mailman/listinfo/edinburgh-pm From asmith9983 at gmail.com Sat Feb 25 11:40:02 2006 From: asmith9983 at gmail.com (asmith9983@gmail.com) Date: Sat, 25 Feb 2006 19:40:02 +0000 (GMT) Subject: [Edinburgh-pm] simple perl question Message-ID: Is it possible to run a perl one line script (i.e. -e option) along with the "-s" switch option ? -- Andrew From chrisb at jesmond.demon.co.uk Sat Feb 25 11:52:19 2006 From: chrisb at jesmond.demon.co.uk (Chris Benson) Date: Sat, 25 Feb 2006 19:52:19 +0000 Subject: [Edinburgh-pm] simple perl question In-Reply-To: References: Message-ID: <20060225195218.A14355@gamma.home> On Sat, Feb 25, 2006 at 07:40:02PM +0000, asmith9983 at gmail.com wrote: > > Is it possible to run a perl one line script (i.e. -e option) along with the > "-s" switch option ? chrisb at gamma:~ $ perl -le 'print "l=$l, e=$e, s=$s"' -s -- -l -e -s l=1, e=1, s=1 Looks like the -s has be * after any -e'' and * before the -- which is also required This is perl, v5.8.0 built for ppc-linux This is perl, v5.8.7 built for i486-linux-gnu-thread-multi -- Chris Benson