Re: [PATCH] XML::Compile::SOAP on Perl 5.6.1
On Thu, Sep 11, 2008 at 11:39:58AM +0200, Mark Overmeer wrote: [is this really something to get London.pm involved in? Let's continue solely on the XML::Compile mailing list after this] * Toby Corkindale ([EMAIL PROTECTED]) [080911 01:38]: The attached patches to Log::Report and XML::Compile::SOAP are enough to get it functional on Perl 5.6, despite the normal requirements for Perl 5.8. I think both patches will make it main stream, with a little rewrite. What about: if ($] = 5.008002) { require Encode; Encode-import; } else { *encode = sub { $_[1] }; } What do you think? Or should it use utf8::downgrade for some subset of older versions? I agree, the *encode method is much neater. I confirm it works on 5.6.1. I'm not familiar with utf8::downgrade - are you suggesting it is available on Perl 5.6.x? (It doesn't look like it to me) thanks, Toby -- Turning and turning in the widening gyre/The falcon cannot hear the falconer; Things fall apart, the centre cannot hold/Mere anarchy is loosed upon the world (gpg --recv-key B1CCF88E)
[PATCH] XML::Compile::SOAP on Perl 5.6.1
Hi, The attached patches to Log::Report and XML::Compile::SOAP are enough to get it functional on Perl 5.6, despite the normal requirements for Perl 5.8. It's horrible so I'm not sure you'd *want* to include this in the main distro, but I thought I'd send it along in case it ever becomes useful for someone else who has to backport an application to a godforsaken ancient non-Linux, non-5.8 production system. :) BTW, aside from the locale and Encode bits, I noticed that HTTP::Response-decoded_content() returns undef (rather than an error, or content) on Perl 5.6 for no apparent reason. I'm sure that can't be right? I don't have a lot of motivation to look into it right now though.. and the versions of modules I'm hitting are all far enough away from current versions so it's probably not worth it. Cheers, Toby -- Turning and turning in the widening gyre/The falcon cannot hear the falconer; Things fall apart, the centre cannot hold/Mere anarchy is loosed upon the world (gpg --recv-key B1CCF88E) Index: XML/Compile/Transport/SOAPHTTP.pm === RCS file: /web/src/rsearch/vendor/soap/XML/Compile/Transport/Attic/SOAPHTTP.pm,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -r1.1.2.1 -r1.1.2.2 23c23,37 use Encode; --- # Commenting out use of Encode, since it doesn't exist on Perl 5.6.1 on prod! # use Encode; if ($] = 5.008) { require Encode; Encode-import; } # This function works around the lack of Encode on Perl 5.6 by.. not encoding # anything. Luckily, StreetAdvisor only sends us ASCII data anyway... sub questionableEncode { my ($encoding, $string) = @_; if ($] = 5.008) { return encode($encoding, $string); } return $string; } 123c137 my $u = encode($charset, $_[0]); --- my $u = questionableEncode($charset, $_[0]); 146c160 my $u = encode($charset, $_[0]); --- my $u = questionableEncode($charset, $_[0]); 157,159c171,177 $response-content_type =~ m![/+]xml$!i ? $response-decoded_content : undef; --- if ($response-content_type =~ m![/+]xml$!i) { if ($] = 5.008) { return $response-decoded_content; } return $response-content; } return undef; Index: Log/Report/Translator/POT.pm === RCS file: /web/src/rsearch/vendor/soap/Log/Report/Translator/Attic/POT.pm,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -r1.1.2.1 -r1.1.2.2 33c33 my $locale = setlocale(LC_MESSAGES) --- my $locale = setlocale(POSIX::LC_MESSAGES)
Re: svk v git + possible gig
On Mon, Sep 08, 2008 at 05:59:26PM +0100, Paul Makepeace wrote: I first heard about svk at the Nordic Perl conf a few years back and it seemed popular. Disappointment ensued however when I looked at the docs. I still to this day have only the most rudimentary understanding of what an smerge is, and the docs seem just as weak. I know people work hard on this project but it just doesn't seem well documented. The FAQ's first entry: * How can I set multi-line properties like svn:ignore? I mean, seriously?! When I've asked others about this I've had agreement and ask on IRC. Anyway, so has anyone moved from svk to git? Any thoughts on the experience? I've been using git for the past year, and am quite liking it. Initial learning curve can be steep for people coming from non-distributed systems like cvs or svn, but there are a lot of guides and HOWTOs out there, and it is exceptionally powerful and *fast* to use. tjc -- Turning and turning in the widening gyre/The falcon cannot hear the falconer; Things fall apart, the centre cannot hold/Mere anarchy is loosed upon the world (gpg --recv-key B1CCF88E)
perl/cgi/IE (eww) issue
Just wondering if anyone can answer a simple problem i've hit.. I have a cgi script (lets call it test.cgi) that does some work and then redirects the browser to the same named file, only with a .xml extension. ie. test.cgi redirects to test.xml Seems trivial enough. it's just a print Location: $basename.xml\n\n really. (There's some actual processing going on here first, so it's not a complete NOP) This works fine on Gecko Opera based browsers. (And probably lynx and everything else) Now, the problem is thus: On IE 5.5, it redirects back to the .cgi script? (Thus causing an infinite loop) Erm, has anyone else encountered this, and/or have ideas on how to fix? tjc. -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: Stupid fucking antivirus software
On Sun, Aug 31, 2003 at 05:50:00PM +0100, Adrian Howard wrote: Tell me about it, just cleared eight of those out of the list's admin queue. 426 since Friday 5pm. That's just the anti-virus bounces. I've given up counting the fardling virus posts. Something around 5000 here, and that's just the ones that made it thru the spam filters! (Since tweaked) (Although you might be surprised (or probably not) at just how effective it is to bounce all emails which are between 85 and 115 kb in size.) tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: DOS/WIN archivers of the mid 1990s
On Tue, Sep 02, 2003 at 10:09:16AM +0100, Roger Burton West wrote: JAR was available in 1996 or so, I think. I still have copies of most of the archivers and compressors I was playing with in those days... anyone remember UC2? HA? SAR? ACB? I remember (and used) UC2 and, I think, HA.. What happened to UC2? tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
XML XML::LibXML declarations issue
I'm probably doing something stupid here, but I have the following problem: I am trying to parse this simple XML: ?xml version=1.0 encoding=UTF-8? vxml xmlns=http://www.w3.org/2001/vxml; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd; version=2.0 meta name=author content=Toby Corkindale/ /vxml I am using XML::LibXML, like so: use strict; use warnings; use XML::LibXML; our $parser = new XML::LibXML; my $filename = 'example.xml'; my $xml = $parser-parse_file($filename) or die(parse xml error on $filename\n); my @nodelist = $xml-findnodes('/vxml/meta'); foreach my $node (@nodelist) { my $name = $node-getAttribute('name'); my $content = $node-getAttribute('content'); print META: [$name] = [$content]\n; } The problem is that although the XML document parses fine, and i can manually trawl through child nodes OK, the findnodes() function doesn't work. It *does* work if I remove the xmlns= line from the vxml declaration. (I can leave the schema stuff in there) Am I doing something wrong here, or is XML::LibXML, or is the VoiceXML standard? tia, Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: XML XML::LibXML declarations issue
On Tue, Aug 26, 2003 at 11:06:37AM -0500, Nigel Hamilton wrote: Mark Fowler wrote: mynamespace:vxml xmlns:mynamespace=http://www.w3.org/2001/vxml; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd; version=2.0 Hands up who thinks XML sucks? Here! here! Just take the XML::Simple documentation, it starts off courageously simple but before you know it you're way past the synopsis and in a world of hurt. The escaping, unescaped, escape characters has been a nightmare, every XML feed seems to blow up in different places. I have to deal with about a million html documents with mis-labelled charset encodings.. :/ (and then parse them with nit-picking XML libraries..) I have found a library that makes intelligent guesses as to the correct encoding though. Bring back tab-delimited! :-) I remember the days when an incorrect character just meant you got a strange hieroglyph on your screen instead of the intended char; and the only time it really mattered was when you were playing nethack ;) tjc.
Re: XML XML::LibXML declarations issue
On Tue, Aug 26, 2003 at 03:12:06PM +0100, Mark Fowler wrote: On Tue, 26 Aug 2003, Robin Berjon wrote: When you call findnodes, you are not providing the necessary namespace context, which is why it works when you remove the namespace but not when it's there. Robin, Mark, many thanks. [snip] I'm not sure if this helps or not, but your document could be written like this: ?xml version=1.0 encoding=UTF-8? mynamespace:vxml xmlns:mynamespace=http://www.w3.org/2001/vxml; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd; version=2.0 mynamespace:meta name=author content=Toby Corkindale/ /mynamespace:vxml The example I was using is actually taken from W3C's spec on VoiceXML 2.0, so I'm not going to go changing anything at the source XML level - but I do understand what you're getting at. I understand the concept of XML namespaces, but evidently I misunderstood how they applied when you had a non-qualified xmlns= declaration in a tag. Ack. Note that 'name' and 'content' are still, confusingly, in the empty namespace (as xmlns doesn't effect them.) Qudos for Dom for drilling this into me at a tech meet. I was at that meet too.. Pity I didn't remember enough! I've implemented the fix using XML::LibXML::XPathContext, which seems to do the trick with it's registerNS function; it does tend to clutter things a bit though. :( The other thing I don't understand is that even when I'm calling findnodes() (the XML::LibXML version) on a node which should already be in the vxml namespace (eg /vxml), i still can't do -findnodes('vxml:meta'). As I understand it, I should at least be able to do that without needing the XPathContext module? Or not.. thanks again, Toby (biscuit^Wpints for you at next meet)
Re: [OT] SQL woes
On Fri, Aug 22, 2003 at 09:54:22AM +0100, Andy Ford wrote: What are the advantages of PostgreSQl over mySQL The first few advantages that come to mind: It scales. :D It supports (several varieties of) transactions. It can write internally consistent backup dumps. It supports write-ahead-logging. (Basically the same deal as journalled filesystems, only in-database; and no, just because you're using ext3fs or reiserfs, doesn't mean you achieve the same thing) It supports stored procedures (in tcl, perl, and plpgsql). It has also supported all the above for quite a while now and has a good track record. MySQL supporters tend to point out things like oh, but mysql supports that now - in the latest alpha CVS snapshot. I currently use mySQL everywhere and it works well - at least for what I need it for!! MySQL is good for some stuff - it used to be a fairly lightweight SQL interface to a some basic backend storage. If you just want to go around inserting and selecting data for your home accounting or your webpage, it's fine. Doesn't use too much memory or CPU, works fine. It's just when you want to deal with large/commercial projects that it tends to fall down. But I tend to use it for everything, as well; on modern hardware the slightly larger footprint of Pg isn't a problem. tjc.
Re: [OT] SQL woes
On Fri, Aug 22, 2003 at 05:13:31PM +0100, Jason Clifford wrote: On Fri, 22 Aug 2003, Simon Wistow wrote: So, to sum up this thread : 1. PostGres has some advantages 2. MySql has some advantages 3. Oracle has some advantages 4. SQLite has some advantages 5. All of the above have disadvantages. 6. There will be a film. At 11. Which will be delayed for a new advertising campaign promoting MS-SQL. The only database written exclusively for MS Windows - so you know it must be good! (Although Sybase wasn't, was it?) tjc.
Re: [OT] SQL woes
On Fri, Aug 22, 2003 at 02:59:14PM +0100, Roger Burton West wrote: On Fri, Aug 22, 2003 at 06:45:21AM -0700, Randal L. Schwartz wrote: In conclusion, if you want a speedy ACID-compliant enforced-business-rules database with full SQL support (not a subset), PostgreSQL wins, and MySQL is still two or three years away. On the other hand, if you wanna be able to ask a question on a general mailing list, the MySQL community is probably ten times the size of the PostgreSQL community, and more applications have been written that presume MySQL's quirky SQL subset. That'd be the *only* reason in my mind to go with MySQL over Pg at this point. On the third hand, if you want _real_ speed, _and_ transactions, but none of the other neat stuff; and if your system doesn't have much in the way of concurrent writes; SQLite is a whole lot easier to set up and admin than MySQL. (I'm using it for most of my light-weight web apps these days.) Transactions, sort-of, in that you get them within a single query; but there's poor support for simultaneous-request stuff. I looked at SQLLIte a while back, and the thing that scared me off was the complete lack of locking; it required you to do that at application level. OK, you say, so it's not too hard to implement one giant all-encompassing lock at application level with a CPAN module; but then you get right back the problems that were plagueing MySQL earlier on! (coarse grained locking). history repeats itself.. tjc. -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: [OT] SQL woes
On Sun, Aug 17, 2003 at 06:03:13PM +0100, Paul Makepeace wrote: On Sun, Aug 17, 2003 at 09:51:13AM -0700, Randal L. Schwartz wrote: (And people who use MySQL wonder what the value of subselects are! :) Subselects are in MySQL 4.1 (currently alpha). http://www.mysql.com/press/release_2003_05.html Ick. Have they got around to supporting transactions yet? :P I'd still say toss it and use PostgreSQL. Ditto. Don't understand the hype around MySQL, personally. tjc
Re: Eurocracy sucks.
On Mon, Jul 14, 2003 at 03:50:41PM +0100, Earle Martin wrote: Some of you may have heard this from me, some not My wife, who is not from within the EU, requires a Schengen Visa[0] to come with me to YAPC::EU. So, I just called the French consulate's visa appointment booking line (which costs a fucking outrageous pound a minute) to try and get her one. oh sh-t.. I'm heading to Germany early next month and don't have any special visa's or anything.. I've never really bothered with them before when visiting euro countries and just waved my passport at people on the way thru. Is this Schengen thing a recent thing? tjc
[OT] room available in Islington
Hi, We have a vacant room in Islington. Rent is £320/month, exclusive of bills, etc. For an extra £6/month, you also get access to the 2MBit ADSL link, which is really quite nice. (Has a static IP and everything) It's in a brilliant area for transport - there are five different busses which go past a stop that's 30 seconds around the corner, so you can get away quickly, and getting home late at night is good too - the N73 practically drops you off on our doorstep. Both Angel and HI stations aren't too far, giving access to the Northern Line and Victoria Line. I need someone to fill the room quickly, as I'm signing a contract for a new place friday - if needs be, you could start moving in on Monday. SOrry for the off-topic post, but hey, there are people who like Perl, and Buffy, living in the house who would be your housemates :) Contact me for more details, -Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: Neural nets
On Mon, Jul 07, 2003 at 03:19:46PM +0100, Andy Wardley wrote: Toby Corkindale wrote: I'm not convinced Perl is the best language to implement such things. Why not? Performance concerns or something else? My experience has been that perl stops performing adequately once you're trying to do math operations over very large quantities of data. I'm comparing this to C or C++. memory usage per-node is much higher, and the time taken to run the math over the node is quite a bit longer. (this vagueness is qualified a bit below) One could write the main bits in C anyway and get to it from Perl via XS, though. But I'd probably just stick to C or C++ all the way in that case. /heretical That's a serious question by the way, not just me being provocative. A cow-orker of mine has just implemented a gesture (as in pen stroke, not up yours matey or swivel on this) recognition net in Ruby and it seems to be doing the job most admirably. Quick to implement, fast enough to run. Now I realise Perl isn't Ruby, but they're close enough to be compared side-by-side against say, C, C++ or Java. Well, no, actually. There's a significant difference in runtime between the same program written in Perl or C. Not really distinguishable to the naked eye until you start scaling up, though. if you don't need to run huge neural nets, or many recognitions per second, then you're probably fine to go for Perl/Ruby/java/etc. Or if someone else has already written an xs interface to a C NN library, then bonus! :) -Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
xslt perl functions
Hi, any XML::LibXSLT gurus able to help out here? I have a XSL template that converts XML to XHTML via the XML::LibXSLT module. So far, fine. I want to be able to use special tags in the XML to signal the XSLT processor to call out to registered perl functions. This works, too, as per the following extract: xml some-xml insert type=foo/ /some-xml - xsl xsl:template match=insert xsl:textthis is an insert clause:/xsl:text xsl:value-of select=insert:thing(@type)/ /xsl:template - perl $xslt-register_function(urn:insert, thing, sub { return 'foo/'; }); -- Currently, the xsl-value-of .../ tag will insert the plain-text that I return from my perl function. This all works fine. However, what I *want* to do, is replace the value-of with the following: xsl:apply-templates select=insert:thing(@type)/ and then, return a bunch of XML from my perl function, which would be processed by any appropriate matches in the XSL. This is the bit that is just not working. I'm hunting thru the source currently, but I wondered if anyone else has done this before me, with any success? Thanks, Toby Notes: just not working being defined as blank output from that xsl clause. The value-of clause will happily display the raw output though, so the function does appear to get called and return fine; debug output from the subroutine is successful too. (ie. warn i am here\n;) I have also tried returning XML::LibXML::Document objects instead of plain-text, and am experimenting with XML::LibXML::NodeList objects as well. -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: xslt perl functions
On Tue, Jul 08, 2003 at 05:39:56PM +0200, Elizabeth Mattijsen wrote: At 08:27 -0700 7/8/03, Toby Corkindale wrote: On Tue, Jul 08, 2003 at 05:15:11PM +0200, Elizabeth Mattijsen wrote: Which version of XML::LibXSLT are you using? If it's CPAN's version 1.54, then you'll need to remove a line from LibXSLT.xs. Or you could get the version from CVS where this seems to be fixed (both just from empirical evidence, rather than from any logic deduction). That would be the version I'm using.. Which line can I try removing? Hmmm... I mixed up versions there. CPAN has 1.53 for XML::LibXSLT, XML::LibXML is now at 1.54. That's right; I'm running those versions - XML::LibXSLT is internally labelled as 1.54 according to the CVS ID tags though, so i figured you meant the version I had.. In any case, it seems that the machine I thought the patched version of LibXSLT.xs was running, actually doesn't have that patch. So I think the incref() kludge is actually enough. I have also tried returning XML::LibXML::Document objects instead of plain-text, and am experimenting with XML::LibXML::NodeList objects as well. Personally I always return NodeLists objects (from findnodes()), but mainly because I checked the handling of that type of return object in the .xs code of the 1.54 version. My experiments in that direction were like $raw = 'foobar//foo'; $xml = $parser-parse_string($raw); return $xml-findnodes('/foo'); That's exactly what I do, but then: return incref( $xml-findnodes( '/foo' ) ); Disappointingly, it doesn't seem to be enough for me; but I'll go play some more and see what I can work out. Further experimentation without the incref() klduge did manage to produce some segfaults, now. Using the kludge prevents those, so its improved something. Unfortunately I'm still getting no output from the apply-templates tag either way. This had the result that the xsl:apply-templates.. dumped a bunch of binary data instead of processing it.. But perhaps this relates to the one-line change you mentioned above? Does this still happen after applying the incref() kludge? the random binary data has gone away - but nothing has replaced it. I'll try with the latest cvs of XML::LibXSLT too, in a moment. many thanks for the help! I owe you a pint.. Would a white wine at the YAPC::EU also be ok? ;-) If only I was going... tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: xslt perl functions
On Tue, Jul 08, 2003 at 06:16:05PM +0200, Robin Berjon wrote: Toby Corkindale wrote: That's exactly what I do, but then: return incref( $xml-findnodes( '/foo' ) ); the random binary data has gone away - but nothing has replaced it. Are you certain that 1) findnodes is returning something and 2) that your stylesheet has a template that matches those? Either of those could produce no output. 1) Yep, had a debug function running which dumped the findnodes output to STDERR. 2) XSLT default template is just print the value, which should have caught things in some way; (assuming i was trying some generic selects) Cheers for the suggestions though. As it happened, the updated LibXSLT module just worked. (Took me a bit to locate the anon cvs server though) ta, Toby (everything appears to have come together now - might be home before it gets dark tonight) -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: Neural nets
On Sat, Jul 05, 2003 at 03:33:31PM +0100, Adrian McMenamin wrote: I see various modules at CPAN and I wonder if anyone has any experience using them and would like to comment? Neural nets in general, yes; Perl versions, no. I'm not convinced Perl is the best language to implement such things. tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: FreeTDS DBD::Sybase Netcool
On Fri, Jul 04, 2003 at 12:45:21PM +, Andy Ford wrote: Anyone had any experience with FreeTDS DBD::Sybase Netcool? I use FreeTDS DBD::Sybase at work to talk to a MS SQL Server - works fine. (Although i do feel a bit dirty afterwards) Haven't used netcool though. What's up? Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: XML::LibXML::Common encodeToUTF8() annoyances
On Thu, Jun 26, 2003 at 12:35:42AM +0100, Andrew Wilson wrote: On Wed, Jun 25, 2003 at 11:00:54AM -0700, Toby Corkindale wrote: Gah! my head-wall; Your head has a wall method! What does it do? hurt...
Re: UK Money, again
On Thu, Jun 26, 2003 at 03:31:31PM +, the hatter wrote: Another obscure but official unit which I occassionally use in the correct context is a jiffy, as in just a jiffy, which is actually 1/50th (or occassionally 1/60th of a second depending on what video standard you're using) Hmm.. Have you checked what the Linux kernel source thinks about jiffies recently? tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: UK Moneyngton, again
On Thu, Jun 26, 2003 at 07:43:14PM +0100, David Cantrell wrote: For shame, Mr. Devers! Oh, for shame! The Manchurian Gambit of 1978 has been considered obsolete since 1981, after Lt. Col. Charles Monkfish (rtd.) demonstrated that no feathers could exist at King's Cross station without being attached to a pigeon. In the words of Monkfish himself: Like, duh! This subthread has reminded me - is platform 9.75 permitted under the current rules? My gaming group couldn't decide, so we treat it like a clone of platform 9, but this seems inelegant. I believe the highly unpopular third edition rules included a requirement that in case of fractions, they be rounded to the nearest integer. In the fourth edition, this change was rolled back to the prior standard of rounding by truncation to the lower whole integer. I know this doesn't result in a solution which is more elegant, but it does give you some leeway to exploit this little-known rule when playing under the appropriate editions of the ruleset. -Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
XML::LibXML::Common encodeToUTF8() annoyances
OK, this is annoying. Code is this: #!/usr/bin/perl use warnings; use strict; use XML::LibXML::Common; my $string = 'This is a test!'; my $decoded = XML::LibXML::Common-encodeToUTF8( 'iso-8859-15', $string ); print Before: $string\nAfter: $decoded\n; However, I get this error printed to STDERR: Usage: XML::LibXML::Common::encodeToUTF8(encoding, string) at ./encoding.pl line 9. I'm failed to find any useful documentation or examples. The only one I found looks almost identical to what i have above. Any suggestions? (either to fix above, or else to do the conversion in some other way...) thanks, Toby (may not reply after tonight until monday unless glasto has ssh terms ;) -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: DBD::Pg - insert_id
On Wed, Jun 25, 2003 at 06:13:27PM +0100, Mark Morgan wrote: Not sure if postgres is similar to oracle, in this respect, but in Oracle, it's illegal to do a currval call until nextval has been called at least once on a sequence. Something that may come to bite you... That is the case; I'm aware of it. Not quite sure where it would be a problem though? (Assuming better error checking and handling than in the quick examples below :) cheers, Toby
Re: XML::LibXML::Common encodeToUTF8() annoyances
On Wed, Jun 25, 2003 at 07:08:42PM +0200, Robin Berjon wrote: You're using it as a method call when in fact it is a function :) You should either: my $decoded = XML::LibXML::Common::encodeToUTF8( 'iso-8859-15', $string ); or use XML::LibXML::Common (:encoding); my $decoded = encodeToUTF8( 'iso-8859-15', $string ); Gah! my head-wall; Well, cheers though :) That just about finished my SQL-query-to-XML convertor. (Used in a PerlTransHandler in Apache to use pseudo-urls, select relevant matching stuff from a DB, convert results to XML, transform with XSLT, display results.) Time for beer now. Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: DBD::Pg - insert_id
On Fri, Jun 20, 2003 at 10:53:47AM +0100, Chisel Wright wrote: One piece of functionality I can't find in the postgres database interface is the equivalent of: $sth-{'mysql_insertid'} It would just be really nice to be able to do something like: $sql = q[INSERT INTO foo (foofield1) VALUES (?)]; $sth = $dbh-prepare($sql); $sth-execute($barbaz); return $sth-{'pg_insertid'}; Can anyone offer some clues? as above, except then return last_inserted_id($tablename); Note that this is quite safe and the value returned is the current value for YOUR session only; so no need to worry about someone else inserting something or other such race conditions. :) # Returns the last ID resulting from an INSERT command sub last_inserted_id { my $self = shift; my $table = shift; #should be safe, but check anyway if ($table =~ /(\w[\w\d\_]+)/) { $table = $1; } else { die(LBHF.pm/last_inserted_id: Invalid table name: $table\n); } my $query = $self-{db}-prepare(SELECT currval(' . $table . _id_seq')); $query-execute or mydie($self, 'SQL Error occured:' . $self-{db}-errstr); return($query-fetchrow_arrayref-[0]); } hope this helps, Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: SQL standards
On Sat, Jun 21, 2003 at 10:03:45AM +0100, [EMAIL PROTECTED] wrote: Here's a link to the SQL 92 BNF http://www.contrib.andrew.cmu.edu/~shadow/sql/sql2bnf.aug92.txt Although I believe PostgreSQL claims SQL99 compatibility in most places? (dunno how that affects stuff from SQL92) tjc
XSLT processor recommendations
Hiya, Given XALAN java, XALAN C++, GNOME libXSLT, and Pure Perl XSLT, which would you choose to work with from Perl, and why? tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: DBD::Pg - insert_id
On Mon, Jun 23, 2003 at 05:16:51PM +0100, Dominic Mitchell wrote: Note that this is quite safe and the value returned is the current value for YOUR session only; so no need to worry about someone else inserting something or other such race conditions. :) Doesn't that depend on whether you're in a transaction or not? I would have thought that you're liable to have it updated if you've got AutoCommit turned on. No, it's still correct even outside of sequences. the current value returned is always the value for your session. I don't know this, I'm just making assumptions about how sequences work. :-) tut tut ;) # Returns the last ID resulting from an INSERT command sub last_inserted_id { my $self = shift; my $table = shift; #should be safe, but check anyway if ($table =~ /(\w[\w\d\_]+)/) { $table = $1; } else { die(LBHF.pm/last_inserted_id: Invalid table name: $table\n); } my $query = $self-{db}-prepare(SELECT currval(' . $table . _id_seq'));$query-execute Hmmm, big assumptions about sequence names here. I merely point this out because I'm continually getting annoyed at postgres for truncating min to 32 chars. This is because I include the table name in my primary key column name though... True, but (currently) that is the way Postgresql generates sequence names from serials. Using this assumption works well enough for my internal code. tjc
Re: XSLT processor recommendations
On Mon, Jun 23, 2003 at 06:11:33PM +0200, Robin Berjon wrote: Toby Corkindale wrote: Given XALAN java, XALAN C++, GNOME libXSLT, and Pure Perl XSLT, which would you choose to work with from Perl, and why? Xalan Java is slow, and to use it from Perl would require shelling out or bridgin from Inline::Java, neither of which are nice. Xalan C isn't, to the best of my knowledge, bridged to Perl. So again, shelling out or XS/Inline::C. Not nice. http://search.cpan.org/author/EDPRATOMO/XML-Xalan-0.44/ It is supported directly; i don't know how well it works though. Pure Perl XSLT, aka XML::XSLT is incomplete and broken. And slow. Just don't go there. XML::LibXSLT is fast and already bridged. It also probably has the highest user-share. I'd call it your only solution. That's the one I have initially started using. So far so good; as everyone else seems to think it's a goer, I'll stick with it. Out of interest, does anyone know how it performs compared to the MS/IIS/XML combo? (Since a solution based upon that is basically the main competitor to my effort) thanks, Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: DBD::Pg, bytea, nulls
On Sun, Jun 15, 2003 at 07:06:32PM +0100, Kate L Pugh wrote: The postgres docs at http://www.postgresql.org/docs/view.php?version=7.3idoc=1file=datatype-binary.html tell me that nulls (\0) need to be escaped when used as part of a string literal. DBD::Pg seems not to escape them for me though: You may need to enable auto-escaping, like so: my $dbh = DBI-connect(dbi:Pg:dbname=$dbname,'','', { pg_auto_escape = 1 }) or die (Failed to connect to db: $!\n); (apologies for messed up indenting) tjc
Re: 501 Not Implemented
On Mon, Jun 16, 2003 at 11:32:13AM +0100, Ben wrote: Now, I know that a 501 SHOULD contain a response body, but that's kind-of not relevant. What I want to know is what server conditions could cause it to think that a 501 is an appropriate thing to send back. Are you able to access the CGI script at all? (ie. via other browsers, or via LWP without posting any data back, etc.) If not, then be aware that some http servers will return 501 when they cannot successfully execute the CGI program. Permissions to GET and POST are able to be specified seperately on most servers, as you know. I've heard that some servers will return 501 when you try to use POST if they've been configured not to use it. (OR if they're just a terribly incomplete implementation, which may be the case for this server you've found?) Suggest you try swapping your method? Lastly, POST data can be encoded in two formats; the www-form-urlencoded type and the form-data type. Incomplete HTTP or CGI implementations may not support the latter type. Try forcing LWP to use the former? tjc
[OT] hardware for sale
Umm. I've come across a Mac Quadra 750. (Or was it 650?) Does anyone want it? Comes with a SCSI HDD and CDROM and so forth. Somehwat more usefully, I also want to get rid of 2 nVidia GeForce 2 MX video cards. Unlike the Mac, I'm interested in getting more in return than just increased floor space. tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: assimilating CPAN
On Wed, Jun 11, 2003 at 04:56:20PM +0100, Nicholas Clark wrote: Arthur Bergman has joined the list of known London.pm-ers on muttley's CPAN leaderboard: http://www.thegestalt.org/simon/perl/ london.pm is now responsible for 9% of CPAN. It would be nice to get over 10%. I should probably register at CPAN and actually upload some of my modules. This would involve me updating modules, creating proper distribution formats, and, worst of all, writing documentation. Maybe one day if i get really bored at work.. tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: The Perl Color?
On Thu, Jun 05, 2003 at 08:43:48AM -0700, Joshua Keroes wrote: Perl is black. That's how it always appears when I type it. :-) Cure colourblindness by typing: :syntax on Toby. -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: international beer summit
On Thu, Jun 05, 2003 at 10:22:40AM +0100, Simon Wistow wrote: On Wed, Jun 04, 2003 at 11:43:43PM -0400, Perrin Harkins said: Great! I'll be there from the 22nd through the 28th and have no plans yet. I'm going to rent an apartment with some friends in Clerkenwell. Nearest underground is Farringdon and Chancery Lane. I smell a trip to the Jerusalem Tavern. Plus, it has some of the nicest beer i've yet tasted in London! (Although I am always happy for someone to reccommend a contender ;) tjc
Re: Reaping process...
On Tue, Jun 03, 2003 at 12:32:41PM +0100, Shevek wrote: On Tue, 3 Jun 2003, Nigel Wetters wrote: Dirk Koopman wrote: I coded a few Perl implementations of the servers from Comer Stevens [0]. The experience was extremely frustrating as performance stank and under high load zombies always became a problem, whatever reaping code I used. I guess reaping is just fragile under high load. Ignore the SIGCHLD. POSIX only guarantees signal delivery within 4 minutes. Just reap a few whenever you get to an appropriate point in your code. Has anyone experimented with signal handling in linux threads in the 2.5 kernels? According to some stuff I've read, it behaves a lot better than under 2.4, but I'm interested to know to what extent. The 2.4 method of delivering signals to sometimes-one, sometimes-all, sometimes-some threads was icky. I used to set a block on all signals, in all threads, and then designate one thread to be a 'signal handler' and unblock signals for it; but this didn't always work as expected. This was 2.4.x kernels, and probably glibc 2.1.3, so I understand it may have improved in later glibc editions? tjc
Re: wget spanning hosts (or: am i going crazy?)
On Sat, May 31, 2003 at 11:45:43PM +0100, David M. Wilson wrote: On Fri, May 30, 2003 at 09:19:09AM -0700, Toby Corkindale wrote: Recompiling wget with --without-ssl fixes the problem. But it still sounds like a bug. Without checking, are you getting the -m and -r options confused? No.. I was originally mirroring, but the bug appears when using just the single -r flag too. Either way, neither option should produce the behaviour of spanning hosts for https: links but not http:. ta, Toby
Re: Reaping process...
On Sun, Jun 01, 2003 at 09:15:27AM -0500, Nigel Hamilton wrote: Here is the code that is trying to reap child processes: use POSIX 'WNOHANG';# see Stein's idiom p. 305 Network Programming with Perl # kill all zombie's including hanging zombies, needed for cleaning up # rogue processes $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) 0 ) { } }; If that's all you are doing, then is there anything wrong with changing it to this? $SIG{CHLD} = 'IGNORE'; tjc
Re: Reaping process...
On Sun, Jun 01, 2003 at 03:36:38PM +0100, Alex Hudson wrote: Any ideas on how to reap subprocesses robustly? ... If I can get the processes to be reaped correctly the machine will be able to stay up ... Don't you have to reinstate the handler once it has been used? E.g.; sub reap { while (waitpid(-1,WNOHANG); $SIG{CHLD} = \reap; } $SIG{CHLD} = \reap; Depends on operating system. I think Linux and some other modern systems maintain the setting, but others (UnixWare?) require it to be re-set. I didn't think zombies put any extra stress on the server though really; I thought they just took up space in the process table (so, an entry of 4kB or something? Less on NPTL Linux, I would imagine). True, they aren't a huge load. Obviously you want to reap them eventually, but they don't cause a huge load in the meantime. I would look towards other things for responsibility for the swapping and crunching. tjc. -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: internet world show tomorrow
On Mon, Jun 02, 2003 at 09:42:57AM +, the hatter wrote: Anyone else going to be there ? Any existing plans for moungers to gather in small corners and discuss current industry trends in the key sectors, buffy and beer ? I am hiding from anything involving buffy, for fear of spoilers. I'm only up to the beginning of S7 myself.. tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: Reaping process...
On Sun, Jun 01, 2003 at 05:41:38PM -0500, Nigel Hamilton wrote: Thanks to everyone who has sent suggestions ... it's tricky ... it does appear that the forking goes out of control... despite the signal handling code even if I get this to work robustly I?m still going to look at other alternatives - under load the response time is too variable. In what way are you limiting the total number of processes? You probably know anyway, but remember that 20 processes that operate without swapping will be way more than twice as fast to finish as 40 processes that run out of memory and swap. So, limit your processes to the machine's capabilities. I'd advise having a squid (or apache) reverse-proxy (ie. accellerator) going here too, as it uses less memory when waiting for the data to feed to a slow client than a bunch of perl processes in your CGI script do. If you're using a fork-method of worker processes, then you're probably going to end up using semaphores as a simple method of keeping track; but it can restrict the methods you use for queueing etc. I suspect i get called heretical for this, but I actually prefer to use threads when it comes to these things. a) better memory efficiency b) easier and more advanced control over queueing and message handling c) added bonus for you - no more reaping! :) That said, threads are more delicate than forks - but if you can code them well, you are rewarded with higher performance. (My threading experience is mainly with C or C++ though, and only limited amount of use on Perl, but same principles apply.) -Toby
Re: Reaping process...
On Sun, Jun 01, 2003 at 09:18:26PM +0100, Lusercop wrote: $SIG{CHLD} = 'IGNORE'; How is that even remotely the same? In the first case, you end up with no zombies, in the second case you end up with a load of them? Admittedly, if [snip] Toby, I'd have expected better from you. :-) -- Lusercop.net - LARTing Lusers everywhere since 2002 Did you actually check the end result from my suggestion before flaming? *shakes head* I would have expected better from... :^) tjc -- Turning and turning in the widening gyre The falcon cannot hear the falconer; Things fall apart, the centre cannot hold; Mere anarchy is loosed upon the world.
Re: Reaping process...
On Mon, Jun 02, 2003 at 05:48:22AM -0500, Nigel Hamilton wrote: In what way are you limiting the total number of processes? I?ve just implemented a pre-forking server so it is limited to the number of pre-forked servers * 10 forks per server - this has improved things a bit. Cool.. Dynamically adjusting number of clients based on load works well too, as you've said below. Best method for checking load on Linux, without incurring much system time, is to open /proc/loadavg and read that. If you seek to start of file and re-read(), you get the updated loadavg, so you don't need to close and reopen it. But the performance of the forking miniserver is a worry - I've implemented a preforking version and although this is better the server still melts. Do you think your server should be doing better than it is? If you don't mind making it public, can I ask what the spec of the machine is, and what sort of performance you're getting? Previously I've implemented this component using Java threads and I also considered Java non-blocking IO but the performance was not as good as perl fork()ed processes - so I gladly reverted to Perl. Yeah, definately better performance from Perl :) I've seen some hideously memory-inefficient Java webservers; best (ahem) effort was from a friend's uni project some time ago.. I think it was chewing about 1.5 Gb of memory to serve not-many pages! :) I'd advise having a squid (or apache) reverse-proxy (ie. accellerator) going here too, as it uses less memory when waiting for the data to feed to a slow client than a bunch of perl processes in your CGI script do. This is a good point I think part of the problem is the duration of some processes ... the little server sits behind apache using mod_proxy .. hmmm ... Hmm, that's good then.. One idea -- Setup sig alarm to trigger on your scripts after a period, and have them transmit the info they've receively so far, then die, when the alarm goes off. Another thing -- Are your processes doing a single task per instance? Could you convert the workers to process (serially) multiple requests? This would save on instantiation costs, which can be substantial. If you're using a fork-method of worker processes, then you're probably going to end up using semaphores as a simple method of keeping track; but it can restrict the methods you use for queueing etc. Yes at the moment I flock a file as a semaphore - there could be some excessive waiting going on here if one of the processes takes too long - I'm reimplementing this now to avoid the flock - I plan to use IO::Select to read from pipes attached to the spawned processes. I've created systems using shared pipes like that before. works ok, remember to turn on autoflush thou :) open() isn't the cheapest system call around; other semaphore/ipc methods can be more efficient. But, open() is fairly portable so suspect that's why it's used a lot. Depending on how much work your children are doing, the cost of the IPC methods may be insignificant though. seeya tjc.
Re: Reaping process...
On Mon, Jun 02, 2003 at 11:59:22AM +0100, Alex Hudson wrote: On Mon, Jun 02, 2003 at 05:48:22AM -0500, Nigel Hamilton wrote: I suspect i get called heretical for this, but I actually prefer to use threads when it comes to these things. a) better memory efficiency b) easier and more advanced control over queueing and message handling c) added bonus for you - no more reaping! :) a + b + c = sounds great. I'm not sure how big a win threads would be in this instance, if any. Most threading libraries are fork()-based anyway - Linux doesn't have 'threads' natively, but a very fast fork() implementation. (Solaris does have threads I believe, not sure about the BSDs). Umm.. Not really. Threads are like fork(), only without the copy/copy-on-write stuff, and everything else in fact. The process table is duplicated, sharing the same memory space, file descriptors, shared libs, and so forth. Creating a new thread under linux is a very fast operation, and task switching between threads is also very fast - check out the code in the kernel to see just how little has to be done. When you have a lot of processes, you save on task-switching if they are all threads instead of forked copies. Since you save a lot of memory, you can run a lot more concurrently than you would if you were using forked processes. Because creating/deleting threads doesn't involve mass memory operations, the operations are quicker. tjc
Re: wget spanning hosts (or: am i going crazy?)
On Fri, May 30, 2003 at 09:05:42AM -0700, Toby Corkindale wrote: [snip] The only thing I can see is that i'm connecting to an HTTPS site rather than http, but still.. that's still a seperate host and shouldn't be recursed into? Should have clarified -- the initial site is HTTP, but the links inside it are to https://. http:// links don't get host-spanned, only the https:// ones do. Recompiling wget with --without-ssl fixes the problem. But it still sounds like a bug. tjc.
Re: Someone must have solved this one ?
On Tue, May 27, 2003 at 07:44:58PM +0100, Nik Butler wrote: Heres a problem for the perl ancients among you. One of our customers ( I say our since like the Borg, ive joined a collective ) requires a regular deduplication of list information ( mostly CSV ) against a existing database (SQL Server 2k) . now im fairly sure that this is exactly what Perl was designed for ... however when searching for tools and advice on utilising those tools I do tend to come up a little non plussed. has anyone actually had experience ( postive or negative ) with such tools in doing mail address deduplication of text files with SQL The laziest method would be to let the SQL server do the work.. eg: CREATE UNIQUE INDEX address_idx ON contacts (sirname, house_number, postcode); However, before you could use this you would have to normalise all your information. For eg: Make sure the postcode was in uppercase with a space seperator. Not hard to do though; it's a once-off for the SQL database, but you'd need to run it on every entry from the new text files. Not a big loss though. I know this is barely using Perl as anything other than an intelligent DB frontend, but you have to admit databases are quite good at doing indexing and so forth - so why try to re-write the wheel? tjc Note: Example above is taken from PostgreSQL, so may not work verbatim on inferior DBs ;)
Re: [ANNOUNCE] Tim O'Reilly in London
On Wed, May 28, 2003 at 10:27:57AM +0100, Mark Fowler wrote: Er, isn't the 'M' in there something to do with , cough, MySQL ... ? Sh. The 'P' is PHP. Or python. Or Perl. Or it seems these days, getting back to John's point, Postgres. I seem to be running FASP these days for ickle applications (FreeBSD, Apache, SQLite and Perl.) These acronyms are all very silly. That would make me a LAPP dog. (But I used to be a UIIC monkey.) tjc ((DEC) UNIX, ISDN, Informix, C)
Re: Dude, where's the pub?
Hi all, I'll turn up at the pub tonight, and the tech meeting. I don't know anyone, but please feel free to come up and say hi to the long-haired lost-looking guy wandering around trying to guess which bunch are the PMs.. Seeya! Toby On Thu, Nov 21, 2002 at 02:07:00AM +, Kate L Pugh wrote: And, who wants to come and have a swift half and an optional bit of food before the tech meet? There will be for definite people at the Islington Tup from at least 6pm. http://grault.net/cgi-bin/grubstreet.pl?The_Islington_Tup,_N1_0QD
Re: perl gtk2 bindings?
On Tue, Nov 19, 2002 at 09:23:40AM +, Tom Insam wrote: On Mon, 2002-11-18 at 23:59, Toby Corkindale wrote: Hi, I wonder if anyone knows the state of perl bindings for gtk-2? There's an alpha release, it vaguely works. API is massively changable right now, though, seems to be a battle between making it behave exactly like gtk2 in C, and making it behave 'sensibly' from a perl point of view. Ah, that fluidness is what i was afraid of.. I'm just trying to write some applets that will work against varying versions of (future) distros. I figured there wasn't any point writing for the (almost) obsolete gtk-1.2 when gtk2 is around and distros are migrating to it. Would prefer to use Perl, since i understand it's database interface well, but looks like maybe C or C++ will be the way I go instead now. I guess it was about time i dived into that area anyway.. Thanks for the mail lists, guys, Toby
Re: MySQL - PostgreSQL migration
On Mon, Nov 18, 2002 at 09:28:49AM -, Mark Buckle wrote: Hhhhm, I'm worried by statements like this :- How close is PostgreSQL to Oracle in terms of its SQL capabilities? It's done everything that I've expected it to. Triggers and SPs can be written in several languages with PostgreSQL. Including Perl, assuming you're entirely mad. Actually, it's not _that_ bad, but still not something I'd want to use in production. Is PostgreSQL ever going to be a database you'd bet the company on ? Mark Actually, it worked better for us than the commercial database previously used (Informix), when I worked for Pracom. At Netcraft Australia, Postgresql *is* the database they bet the company on, as you put -- and Postgresql and Netcraft Australia won, bigtime. I wouldn't use anything else these days - I have heard that Oracle is better in some undefineable way when used with very large datasets or in some circumstances, but I'm yet to encounter any of these situations while working for nationwide companies. I'd be very interested to hear if anyone has actually had real life situations where Postgresql just 'wasn't good enough'. -- and where the Postgresql DB was implemented well. TJC
perl gtk2 bindings?
Hi, I wonder if anyone knows the state of perl bindings for gtk-2? ta, tjc
re: [JOB] I need one - results?
Hi, I just wondered if we could have some feedback from the various ppl who posted to the list looking for work a while ago? Did you get any offers? I'm in a similar situation.. just moved to London recently.. hoping to find some work in a decent UNIX-orientated workplace, pref with Perl or gcc. ta, Toby