Re: Getting the "latest" related record from a SQL DB

2014-10-10 Thread Matt Lawrence
On 10/10/14 13:21, David Cantrell wrote: On Thu, Oct 09, 2014 at 04:56:22PM +, Adam Witney wrote: Could you select all albums, ORDER BY date DESC LIMIT 1 ? I don't think that LIMIT is standard SQL so it won't be supported everywhere. And also I don't think that useful things like DBIx::Cla

Re: sub signatures coming

2014-02-25 Thread Matt Lawrence
On 25/02/14 11:18, James Laver wrote: On 25 Feb 2014, at 03:45, Paul Makepeace wrote: On Mon, Feb 24, 2014 at 2:04 PM, Steve Mynott wrote: http://perltricks.com/article/72/2014/2/24/Perl-levels-up-with-native-subroutine-signatures Finally. But don't believe the python/perl comparison troll,

Re: Bug?

2013-12-09 Thread Matt Lawrence
On 09/12/13 11:23, Kieren Diment wrote: In a short subroutine, this: use List::Util qw/shuffle/; my @list = @{$self->answer_list_orig_order}; @list = shuffle @list if $self->random_order; return \@list; does what's expected. Returns the shuffled list. This: use List::Util

Re: Regex teaser

2013-12-04 Thread Matt Lawrence
On 04/12/13 10:15, Smylers wrote: I agree the behaviour isn't immediately obvious. But it does make sense when thinking about what each component means separately. So what does seem bug-like to me is the Python behaviour — can anybody explain that? It looks like Python has decided that a zero-w

Re: Regex teaser

2013-12-04 Thread Matt Lawrence
On 04/12/13 07:55, Paul Makepeace wrote: On Tue, Dec 3, 2013 at 5:03 PM, Mark Fowler wrote: On Tue, Dec 3, 2013 at 6:54 PM, Paul Makepeace wrote: $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a' This is where tools like Regexp::Debugger shine. Running perl -le 'use Regexp::Debugger; (

Re: Database Design Advice

2013-11-18 Thread Matt Lawrence
On 18/11/13 11:18, Philip Skinner wrote: Auto-increment a double column primary key, something like: uid int(11) not null auto_increment, revision int(11) not null auto_increment, primary key(uid, revision) ; works in mysql. You won't have your concurrent query issues there, for the most par

Re: Perl 5.16 vs Ruby 2.0 UTF-8 support

2013-08-23 Thread Matt Lawrence
On 23/08/2013 19:45, James Laver wrote: - UTF-8 is a great interchange format. But it's quite annoying perl doesn't have a flag to automatically en/decode to/from UTF-8 as regards STDIN and STDOUT (and in the case of STDIN, probably anything that <> uses) Doesn't the -C switch count? Or indee

Re: Using grep on undefined array

2013-08-14 Thread Matt Lawrence
On 14/08/13 13:12, Abigail wrote: On Wed, Aug 14, 2013 at 08:58:05AM +0100, Matt Freake wrote: I don't think the original poster is confusing those two, and when I applied 'use strict' to the original code (with the sub) it didn't help (no warnings or errors). The bit I'm stuck on is why does

Re: Using grep on undefined array

2013-08-14 Thread Matt Lawrence
On 14/08/13 08:33, William Blunn wrote: On 14/08/2013 00:09, Andrew Beverley wrote: Could someone please explain to me why the following outputs an empty string rather than "*"? In this case it may be wise to show a “use strict;”, which I assume is in effect here, otherwise people can just sa

Re: Using grep on undefined array

2013-08-14 Thread Matt Lawrence
On 14/08/2013 00:09, Andrew Beverley wrote: Hi, Could someone please explain to me why the following outputs an empty string rather than "*"? get(); sub get($) { my $fields = shift; my @fields = grep $_ ne 'domain', @$fields; my $select_fields = $fields ? join(',', map { 'users.' .

Re: Assigning anonymous hash to a list

2013-07-30 Thread Matt Lawrence
Don't you need parentheses on both sides of that assignment?  Sent from Samsung Mobile Original message From: gvim Date: To: London PM Subject: Assigning anonymous hash to a list Can anyone explain why this works: my $ref = {a => 1,  b => 2, c => 3}; say $ref->{b};   

Re: Living with smart match breakage

2013-07-04 Thread Matt Lawrence
On 04/07/13 13:03, Abigail wrote: On Thu, Jul 04, 2013 at 12:40:34PM +0100, Gareth Harper wrote: On 4 July 2013 12:23, Abigail wrote: And it is: $ /opt/perl/5.8.9/bin/perl -le 'BEGIN {print $]} use feature;' 5.008009 Can't locate feature.pm in @INC (@INC contains: ... .) at -e li

Re: [OT] blessed sub-refs in the symbol table

2013-02-01 Thread Matt Lawrence
On 01/02/13 09:21, Nicholas Clark wrote: On Thu, Jan 31, 2013 at 11:12:30AM +, David Cantrell wrote: I am most disappointed to find that if you put a blessed sub-ref in the symbol table and then replace it, its DESTROY method doesn't get called straight away: package Immortal; sub new { re

Re: [OT] blessed sub-refs in the symbol table

2013-01-31 Thread Matt Lawrence
On 31/01/13 11:12, David Cantrell wrote: I am most disappointed to find that if you put a blessed sub-ref in the symbol table and then replace it, its DESTROY method doesn't get called straight away: package Immortal; sub new { return bless sub { print "called the object\n" }, shift; } sub DEST

Re: That simple?

2012-04-24 Thread Matt Lawrence
It might be a good idea to binmode that handle, just in case there's CRLF or unicode translations on by default. I think just changing the mode in open() to '<:raw' will do the trick. The only other problem I can see is that errors in read() won't be handled particularly nicely, afaict this wi

Re: Strange things are occurring at compile time

2012-03-01 Thread Matt Lawrence
Anonymous subroutines without references to external variables that have identical bodies are identical subroutines. $ perl -le 'push @subs, sub { print "Hello" } for 0 .. 3; print for @subs' CODE(0x94be884) CODE(0x94be884) CODE(0x94be884) CODE(0x94be884) $ perl -le 'for my $value (0 .. 3) { pu

Re: Dim Sum tomorrow?

2012-02-16 Thread Matt Lawrence
On 15/02/12 21:57, Dave Hodgkinson wrote: Sent from my iPhone On 15 Feb 2012, at 21:48, Peter Corlett wrote: On 15 Feb 2012, at 15:10, Dave Hodgkinson wrote: Anyone round the West End fancy parcels of tasty goodness and Lo Bak Gao tomorrow? New World? 1pm? I'm up for that, although I note

Re: v0.6 != v0.6.0 ?

2011-10-18 Thread Matt Lawrence
On 18/10/11 11:19, Chisel wrote: Is this expected behaviour? I get lost in what versions should and shouldn't numify. It definitely doesn't DWIM. ➔ perl -Mversion -le '$big=version->new("0.6.99"); $small=version->new("0.6"); print $big; print $small; print $big>$small ? "ok":"wuh?"' 0.6.99 0.6

Re: Cool/useful short examples of Perl?

2011-06-09 Thread Matt Lawrence
On 08/06/11 18:19, Philip Newton wrote: On Wed, Jun 8, 2011 at 15:37, Matt Lawrence wrote: Perl's canonical true and false are 1 and '' respectively Is that so? How would one find that out? Dump-ing 4==4 and 4==5 with Devel::Peek implies to me that true and false are PVN

Re: Cool/useful short examples of Perl?

2011-06-08 Thread Matt Lawrence
On 08/06/11 13:41, Paul Makepeace wrote: On Wed, Jun 8, 2011 at 13:17, Tom Hukins wrote: On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote: I'd rather go for sacking people that don't know the difference between if (something) { ... } and unless (!something) { ... } It's su

Re: Perl under MacOS X

2011-06-02 Thread Matt Lawrence
On 02/06/11 09:06, Kieren Diment wrote: On 02/06/2011, at 5:55 PM, Randy J. Ray wrote: I find myself the unexpected caretaker of a MacBook Pro, handed off to me when someone at $JOB left recently. It's shiny. And very eye-candy-ish. But I am now wishing I'd paid more attention to recent discu

Re: Delete *really* means delete

2011-02-24 Thread Matt Lawrence
On 24/02/2011 18:35, Simon Wistow wrote: sub undef_at_underscore { $_[0] = undef; } This will remove the caller's reference to the invocant, There's no way of knowing if that's the last reference, copying will keep it alive. (my $bar = $foo)->undef_at_underscore; # $foo is still defined.

Re: Shell-fu

2011-02-23 Thread Matt Lawrence
Jérôme Etévé wrote: !-2 That would be the whole command, not the last argument. On 23 February 2011 17:17, David Cantrell wrote: What line-noise should I type to get the last argument to the command two steps back in my history? Obviously I only care about bash.

Re: Shell-fu

2011-02-23 Thread Matt Lawrence
David Cantrell wrote: $ svn add lib/Hlagh/Blagh.pm ... $ svn commit ... $ vi !($^*%*$ What line-noise should I type to get the last argument to the command two steps back in my history? Obviously I only care about bash. And in the general case, what gives me the Nth argument from the command M

Re: Server side chart/graph library?

2011-01-06 Thread Matt Lawrence
Roger Burton West wrote: On Thu, Jan 06, 2011 at 11:54:39AM +, J??r??me Et??v?? wrote: Unicode woes abound :-/ I've got experience with gd but I remember struggling with unicode and antialiasing and there's been no new version since 2007. I'm wondering if anything more modern is aroun

Re: Stand up comedy

2010-06-11 Thread Matt Lawrence
Nicholas Clark wrote: During the beer track at the German Perl Workshop, I was asked "what's a good place to go to in London for an evening of stand up comedy?" and I had no clue. There's The Comedy Store, if you can get tickets. There's often a queue down the street before the doors open o

Re: Posting to blogger.com?

2010-06-04 Thread Matt Lawrence
Matt Lawrence wrote: The real test is whether chr $u > 255. Of course the data is passed through correctly whether or not perl understands that it's unicode data. I said chr here, but I just noticed that I really meant ord *sigh* Matt

Re: Posting to blogger.com?

2010-06-03 Thread Matt Lawrence
Kieren Diment wrote: On 03/06/2010, at 8:06 PM, Steve Mynott wrote: On Wed, Jun 02, 2010 at 05:52:40PM +0100, Mark Fowler typed: On Wed, Jun 2, 2010 at 4:29 PM, Dave Hodgkinson wrote: On 2 Jun 2010, at 21:38, Egor Shipovalov wrote: use File::Slurp; This

Re: Please Meet Me For An Emergency Social Tomorrow

2010-02-16 Thread Matt Lawrence
Dominic Thoreau wrote: On 16 February 2010 10:14, James Laver wrote: On Tue, Feb 16, 2010 at 10:01:20AM +, Dominic Thoreau wrote: This is one of those things I'd like TV writers to stop with, please. Pubs with waiters? Hah! Or... LMC is from Portugal, where drinking establ

Re: TT and UTF8?

2010-01-29 Thread Matt Lawrence
Joel Bernstein wrote: On 29 January 2010 16:59, Matt Lawrence wrote: Joel Bernstein wrote: On 29 January 2010 15:25, Dave Hodgkinson wrote: IIRC, you can say ":set bomb" in vim to do this. Someone set up us the &^&^!^ytNO CARRIER I first enc

Re: TT and UTF8?

2010-01-29 Thread Matt Lawrence
Joel Bernstein wrote: On 29 January 2010 15:25, Dave Hodgkinson wrote: On 29 Jan 2010, at 14:48, Ash Berlin wrote: 2) stick a BOM in the .tt file BOM? U+FEFF - unicode codepoint used to indicate endianness in encodings where word length is not single octet multiples.

Re: Journey Planner

2010-01-27 Thread Matt Lawrence
James Laver wrote: On Wed, Jan 27, 2010 at 12:42 PM, Smylers wrote: Hi. Does anybody know a way of making the TFL Journey Planner show the best route between two places only on transport which has the normal zone-based billing? For travelling from Zone 1 to hotels near Stockley Park it kee

Re: Weird IPC/Apache issue

2010-01-19 Thread Matt Lawrence
Randy J. Ray wrote: I have a module that uses IPC::Open3 (or IPC::Open2, both exhibit this problem) to call an external binary (bogofilter in this case) and feed it some input via the child-input filehandle, then reads the result from the child-output handle. The code works fine when run in most

Re: SHA question

2010-01-14 Thread Matt Lawrence
Matthew Boyle wrote: David Cantrell wrote: On Thu, Jan 14, 2010 at 02:02:51PM +0100, Philip Newton wrote: That reminds me of how I was disappointed to find that rsync generally transfers complete files (rather than diffs) if both source and destination are on a local file system -- before I re

Re: SHA question

2010-01-14 Thread Matt Lawrence
David Cantrell wrote: On Thu, Jan 14, 2010 at 02:03:33PM +, Roger Burton West wrote: On Thu, Jan 14, 2010 at 01:59:22PM +, David Cantrell wrote: Shame that "local" includes "at the other end of a really slow NFS connection to the other side of the world". Mind you, absent runnin

Re: WSDL fun

2009-08-21 Thread Matt Lawrence
XML::Compile::WSDL might do the trick. I certainly found it a lot easier to get something working with that than I did with SOAP::WSDL or SOAP::Lite->service(...), although I must say the documentation isn't that great. Matt Paul Makepeace wrote: Has anyone had experience with turning a .wsd

Re: Quick and dirty convertion to HTML

2009-05-15 Thread Matt Lawrence
.. and Spreadsheet::ParseExcel::Simple might be closer to what you want than Spreadsheet::ParseExcel. The nuts and bolts get hidden from you. Matt Matt Lawrence wrote: wvware may help with the Word documents. http://linux.die.net/man/1/wvhtml Matt Michael Lush wrote: I'm writing

Re: Quick and dirty convertion to HTML

2009-05-15 Thread Matt Lawrence
wvware may help with the Word documents. http://linux.die.net/man/1/wvhtml Matt Michael Lush wrote: I'm writing a CGI text checking tool (on a CentOS server) I'd like to allow users to upload Excel, Word and pdf files and have them displayed as an HTML approximation. I've had a look at S

Re: Unicode to Hex - Pack possibly?

2009-04-17 Thread Matt Lawrence
James Laver wrote: On 17 Apr 2009, at 16:11, abhishek jain wrote: Hi,I need to convert a text written in Devanagari (Hindi) Language into Hexadecimal language. I know we can do in perl , possibly with pack / unpack but not how to do so Can anyone here help? You're going to have to be a bit

Re: system() with timeout

2009-04-17 Thread Matt Lawrence
Chisel Wright wrote: On Fri, Apr 17, 2009 at 11:25:54AM +0100, Matt Lawrence wrote: I haven't had a chance to test any of this on the latest perl, 5.8.8 is the latest I've tried it with. Odd, I'm on 5.8.8 and don't seem to be seeing the same behaviour: [...] Ooo

Re: system() with timeout

2009-04-17 Thread Matt Lawrence
Aaron Crane wrote: Matt Lawrence writes: I recently discovered that die() inside a signal handler causes a memory leak.[...] I guess that might be related to the problem you were having before timing out system(). Unlikely. [...] There's an additional problem when the under

Re: system() with timeout

2009-04-17 Thread Matt Lawrence
Nicholas Clark wrote: On Fri, Apr 17, 2009 at 09:24:01AM +0100, Matt Lawrence wrote: I recently discovered that die() inside a signal handler causes a memory leak. I don't know if that would be a problem for you in this case. Hmm, that's not good. Have you been able to na

Re: system() with timeout

2009-04-17 Thread Matt Lawrence
David Cantrell wrote: On Thu, Apr 16, 2009 at 07:44:39PM +0100, David Cantrell wrote: On Thu, Apr 16, 2009 at 06:32:08PM +0100, Paul LeoNerd Evans wrote: On Thu, Apr 16, 2009 at 06:18:45PM +0100, David Cantrell wrote: Anyone recommend a module to give me something like system(@l

Re: Empty Hash Values

2009-04-14 Thread Matt Lawrence
Jasper wrote: Adrian and I had a tiny chat about this in work, and he decided that subs that return a scalar should return undef explicitly (if they are just returning), and those that return a list should return. At the time I thought it seemed very sensible, but I'm on the fence again. Diffic

Re: Empty Hash Values

2009-04-12 Thread Matt Lawrence
Nigel Peck wrote: When I create a hash like this: my $hash = { element_1 => 'example', element_2 => $var, element_3 => $var2 }; If $var is undefined, then the value of 'element_2' becomes 'element_3'. Not what I want. That doesn't ever happen with scalar values, defined or not. Th

Re: ExtUtils::Installed vs pminst vs?

2009-04-06 Thread Matt Lawrence
Paul LeoNerd Evans wrote: On Thu, Apr 02, 2009 at 11:42:32AM +0100, Paul LeoNerd Evans wrote: On Tue, 31 Mar 2009 19:26:37 +0100 Matt Lawrence wrote: Module::Util will do this for you: A surprisingly-useful looking module. I wonder why I haven't come across this one b

Re: ExtUtils::Installed vs pminst vs?

2009-04-02 Thread Matt Lawrence
Paul LeoNerd Evans wrote: On Tue, 31 Mar 2009 19:26:37 +0100 Matt Lawrence wrote: Module::Util will do this for you: A surprisingly-useful looking module. I wonder why I haven't come across this one before... Is it widely used? I notice it doesn't have a debian package. A

Re: ExtUtils::Installed vs pminst vs?

2009-03-31 Thread Matt Lawrence
David Cantrell wrote: On Sun, Mar 29, 2009 at 03:14:27PM +0100, Minty wrote Holy wars aside, is there a cross platform friendly way to get a list of what modules I have available? File::Find::Rule->file()->name('*.pm')->in(@INC); then apply appropriate transmogrifications to the list to

Re: Today's MySQL Suckage

2009-01-23 Thread Matt Lawrence
Jonathan Stowe wrote: 2009/1/23 Denny : On Fri, 2009-01-23 at 09:52 +, Andy Wardley wrote: /* This table defines users of the system who are Buffy fans. */ $ mysql < my_db_schema.sql It's interpreting the line "system who are Buffy fans." as a shell

Re: Today's MySQL Suckage

2009-01-23 Thread Matt Lawrence
Paul Makepeace wrote: On Fri, Jan 23, 2009 at 9:52 AM, Andy Wardley wrote: I have a file which defines a MySQL database schema. It looks a bit like this: /* This table defines users of the system who are Buffy fans. */ CREATE TABLE buffy_fans ( ..etc... ); I feed it in

Re: DBI, BLOBS, MySQL

2009-01-12 Thread Matt Lawrence
Richard Huxton wrote: Paul Makepeace wrote: What does 'show table files;' give you? You might have the wrong type of blob/text. http://dev.mysql.com/doc/refman/5.0/en/blob.html "If a TEXT column is indexed, index entry comparisons are space-padded at the end. This means that, if the i

Re: Perl Christmas Quiz

2008-12-15 Thread Matt Lawrence
Avleen Vig wrote: On Fri, Dec 12, 2008 at 9:50 AM, Chris Jack wrote: 3) Write a Perl function that takes two references to arrays and returns the intersect of them. If an entry appears n times in array 1 and m times in array 2, the output should list that entry min(n,m) times. Bonus mark f

Re: Audiofile::Info

2003-09-09 Thread Matt Lawrence
Rafael Garcia-Suarez wrote: Dan Brook wrote: use vars '%INC'; useless use of "use vars" : the INC symbol is exempt from strict-vars errors. Or do you use a buggy version of perl that I don't know about ? No, I was just keeping my own copy of %INC so it didn't interfere with the main %INC. INC i

Re: Calling subroutines.

2003-08-01 Thread Matt Lawrence
Andy Williams (IMAP HILLWAY) wrote: Hi, I want to be able to do something like the following: my $method = shift(@ARGV); my @vars = @ARGV; eval { &$method(@vars); }; if ($@) { die "Method doesn't exist"; } sub METH1 { my @passed_vars = @_; print "Welcome to meth

Re: Avoiding $1, $2, ...

2003-07-29 Thread Matt Lawrence
Jasper McCrea wrote: Matt Lawrence wrote: Jasper McCrea wrote: Paul Makepeace wrote: I'd like to dump regex matches into an array without explicitly naming $1, $2, ... =head1 NOT WORKING CODE ($month, $day, $time, $host, $process, $pid, $message) = /^(\w+) (\d+) (\d\

Re: Avoiding $1, $2, ...

2003-07-29 Thread Matt Lawrence
Jasper McCrea wrote: Paul Makepeace wrote: I'd like to dump regex matches into an array without explicitly naming $1, $2, ... =head1 NOT WORKING CODE ($month, $day, $time, $host, $process, $pid, $message) = /^(\w+) (\d+) (\d\d+:\d\d:\d\d) (\w+) ([()\w\/]+)\[(\d+)\]: (.*)$/ || /

Re: Verbose output idiom

2003-07-24 Thread Matt Lawrence
-- - Original Message - DATE: Thu, 24 Jul 2003 14:59:31 From: Shevek <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Cc: >On Thu, 24 Jul 2003, Matthew Lawrence wrote: > >> Shevek wrote: >> >> >On Thu, 24 Jul 2003, Clayton, Nik [IT] wrote: >> > >> >{ # It's a scope! >> >

XML::DOM trouble

2003-07-11 Thread Matt Lawrence
XML::DOM is acting very strangely with regard to UTF-8. I have an XML file encoded in valid UTF-8 which I want to transform into an XML file with a different structure. However, the resulting XML files are suddenly not valid UTF-8 even though I haven't mucked about with any of the character dat