From tom at eborcom.com Mon Jun 4 12:15:59 2007 From: tom at eborcom.com (Tom Hukins) Date: Mon, 4 Jun 2007 20:15:59 +0100 Subject: London.pm Teach In In-Reply-To: References: Message-ID: <20070604191559.GA12628@eborcom.com> Dave has put the slides from this weekend's teach-in online: http://www.mag-sol.com/train/teachin/ If you couldn't make it, spent Saturday outdoors in the sun, or were fast asleep, you might want to take a look. See you all on the 26th, Tom From tom at eborcom.com Tue Jun 5 03:15:08 2007 From: tom at eborcom.com (Tom Hukins) Date: Tue, 5 Jun 2007 11:15:08 +0100 Subject: Problem with SOAP::Lite and Escaping Characters Message-ID: <20070605101508.GA35903@eborcom.com> I'm fairly new to SOAP and have encountered a problem with characters that need escaping in XML. I've tracked down the problem to this code: foreach my $key (keys %in) { push @elems, SOAP::Data->name($key => $in{$key}) ->type($type{$key}); } %in contains key/value pairs that I want to serialise in the request and %type contains a set of mappings for data types associated with each key. Everything works wonderfully until I pass in something with a value containing an '&'. SOAP::Lite doesn't escape this, and it seems not to escape other special characters such as '<'. If I replace these with escaped versions, such as '&' and '<', everything works. I could manually process the keys in %in, but I wondered if I can get SOAP::Lite to do this for me. Or have I missed a better approach? Tom From tom at eborcom.com Tue Jun 5 04:17:35 2007 From: tom at eborcom.com (Tom Hukins) Date: Tue, 5 Jun 2007 12:17:35 +0100 Subject: Problem with SOAP::Lite and Escaping Characters In-Reply-To: <20070605101508.GA35903@eborcom.com> References: <20070605101508.GA35903@eborcom.com> Message-ID: <20070605111735.GA37744@eborcom.com> So it's bad form to reply to my own question, but I figured out my mistake: On Tue, Jun 05, 2007 at 11:15:08AM +0100, Tom Hukins wrote: > push @elems, SOAP::Data->name($key => $in{$key}) > ->type($type{$key}); Replacing $in{$key} with SOAP::Data->value($in{$key}) does the cleverness I was after. I blame the caffeine. Tom From patelxx at hotmail.com Fri Jun 8 08:27:53 2007 From: patelxx at hotmail.com (Ravi Patel) Date: Fri, 08 Jun 2007 15:27:53 +0000 Subject: Pinging the Server and saving the status on a CSV file. Message-ID: An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20070608/1df88a57/attachment.html From jns at gellyfish.com Fri Jun 8 09:08:54 2007 From: jns at gellyfish.com (Jonathan Stowe) Date: Fri, 08 Jun 2007 17:08:54 +0100 Subject: Pinging the Server and saving the status on a CSV file. In-Reply-To: References: Message-ID: <1181318934.8333.83.camel@coriolanus.gellyfish.com> On Fri, 2007-06-08 at 15:27 +0000, Ravi Patel wrote: > Guy's, > > I'm a beginner PERL developer and I need some guidance on the > following problem by starting me off with some coding? I have studied > the Net::Ping module in CPAN, it's linking this code to create a CSV > file is causing me difficultly. Not sure what to do? > > The Problem: > > I am going to set up a Server status area on our companys website > (sits on server A), the PERL coding will PING two other servers > (server B & C) to see their currently status every 5 mins. Right, well that's all fairly simple: #!/usr/bin/perl use strict; use warnings; use Net::Ping; use CGI qw(:standard); my @servers = qw(localhost crm-p-pbs01 rabelais); my $ping = Net::Ping->new(); print header(-Refresh => 300); print < EOHTML foreach my $host ( @servers ) { my $status = $ping->ping($host) ? 'ALIVE' : 'DEAD'; print < EOHOST } print "
$host$status
"; I'll leave nicely templating it and making it use an external configuration file as an exercise. I'm not quite sure where the CSV part comes in though. > Finally which protocol will I be using? Well there are two things that you need to balance - on most systems only the superuser can use ICMP to do a true 'ping' however it is equally possible that the TCP (or UDP) echo service might be disabled on a host you want to check for "security reasons". I've just used the default TCP on the above. > > Thank you > > Ravi > > > ______________________________________________________________________ > Play your part in making history - Email Britain! > _______________________________________________ > MiltonKeynes-pm mailing list > MiltonKeynes-pm at pm.org > http://mail.pm.org/mailman/listinfo/miltonkeynes-pm From patelxx at hotmail.com Fri Jun 8 09:22:31 2007 From: patelxx at hotmail.com (Ravi Patel) Date: Fri, 08 Jun 2007 16:22:31 +0000 Subject: Snail::CSV - Trying to understand how CSV work? Message-ID: An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20070608/2e9fd9bf/attachment.html From tom at eborcom.com Mon Jun 11 06:41:11 2007 From: tom at eborcom.com (Tom Hukins) Date: Mon, 11 Jun 2007 14:41:11 +0100 Subject: Snail::CSV - Trying to understand how CSV work? In-Reply-To: References: Message-ID: <20070611134110.GA23769@eborcom.com> Hi, Ravi. On Fri, Jun 08, 2007 at 04:22:31PM +0000, Ravi Patel wrote: > Can someone help me understand what the following Basic CSV example > does? It looks like you've lifted this example from Snail::CSV's documentation. What don't you understand about it? How did the code's behaviour differ from what you expected when you ran it? Here's a brief explanation: > use Snail::CSV; > use Data::Dumper; Here you define the modules you want to use. > my $csv = Snail::CSV->new(); And here you create a Snail::CSV object to work with. > $csv->setFile("lamps.csv", [ "id", "name", "pq" ]); > # or > $csv->setFile("lamps.csv", [ "id", "", "pq" ], { 'pq' => sub { my $pq = shift; $pq > 2 ? 1 : 0; } }); You call the setFile method on this object and pass some data to it. The module's documentation tells us that the first argument, lamps.csv, contains the filename you want to work with; the second contains a list of field names, ('id', 'name' & 'pq' in the first example; 'id' an unnamed field and 'pq' in the second example); and the optional third argument contains a filter. The documentation neglects to mention what filters do, but I guess the allow you to affect how you process the CSV. > my $lamps = $csv->parse; Then you read the CSV file into a data structure called $lamps. > print Dumper($lamps); And this shows you what that data structure looks like. But before you get too involved with Snail::CSV, I'd suggest you take a look at the more commonly used CSV parsing modules on CPAN. I prefer Text::xSV; others like Text::CSV_XS (or its Text::CSV_PP pure perl alternative). Also, please try to mail the list in plain text, or at least with a plain text version of the HTML you send as it's easier to reply to and helps subscribers who read the list's digest. All the best, Tom From patelxx at hotmail.com Tue Jun 12 06:10:31 2007 From: patelxx at hotmail.com (Ravi Patel) Date: Tue, 12 Jun 2007 13:10:31 +0000 Subject: How to display PERL coding "Results" on webpages? Message-ID: An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20070612/fe69f7e0/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: hostPing.pl Type: application/octet-stream Size: 460 bytes Desc: not available Url : http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20070612/fe69f7e0/attachment.obj From tom at eborcom.com Tue Jun 12 07:01:57 2007 From: tom at eborcom.com (Tom Hukins) Date: Tue, 12 Jun 2007 15:01:57 +0100 Subject: How to display PERL coding "Results" on webpages? In-Reply-To: References: Message-ID: <20070612140157.GA36064@eborcom.com> On Tue, Jun 12, 2007 at 01:10:31PM +0000, Ravi Patel wrote: > How to display PERL coding "Results" on webpages? What I'm trying to do is > to display the result of the following PERL code on to a webpage and its > not working. What can I do? It looks like you've modified the code Jonathan posted on Friday, removing the CGI module and the call to its header() subroutine. If you don't use CGI, or something similar, your code won't work as a CGI script. Tom From jns at gellyfish.com Tue Jun 12 07:17:56 2007 From: jns at gellyfish.com (Jonathan Stowe) Date: Tue, 12 Jun 2007 15:17:56 +0100 Subject: How to display PERL coding "Results" on webpages? In-Reply-To: References: Message-ID: <1181657876.6978.21.camel@coriolanus.gellyfish.com> On Tue, 2007-06-12 at 13:10 +0000, Ravi Patel wrote: > Guy's, > > How to display PERL coding "Results" on webpages? What I'm trying to > do is to display the result of the following PERL code on to a webpage > and its not working. What can I do? You are not send any headers - at the very least you have to send a Content-Type: header followed by two newlines before any other content. As demonstrated by the example I gave for your previous question, you can achieve this by inserting: use CGI ':standard'; print header(); after the "use warnings;" You probably want to read the documentation for the CGI manual as well as the specification for the CGI: http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm http://www.ietf.org/rfc/rfc3875 > > Please see attachment. Sending attachments (and HTML and so forth) to mailling lists is not ideal as some software will remove them - for small snippets such as this you are better off putting it in the body of the message. From tom at eborcom.com Mon Jun 25 01:20:43 2007 From: tom at eborcom.com (Tom Hukins) Date: Mon, 25 Jun 2007 09:20:43 +0100 Subject: Meeting Tomorrow, Tuesday 26th June 2007 Message-ID: <20070625082043.GA35969@eborcom.com> The last Tuesday of the month has almost stealthily crept up on us again so it's time for a JIT announcement: Join us for the monthly Milton Keynes Linux and Perl social meeting. The topics of conversation vary, so if you write, use or think about any sort of open source software you might find it interesting. If you don't, there will be beer and you're still welcome to come along. As usual, we will meet at the Wetherspoon's near the railway station (not the one in the snow dome): http://miltonkeynes.openguides.org/?J.D_Wetherspoon%2C_Central_Milton_Keynes I'll be there from around 8pm, but you should arrive and leave whenever suits you - people usually come and go throughout the evening. A few of us usually eat at the pub. If you're worried you might not spot us, please ask off-list for my mobile number. Sometimes we have laminated penguins and there's usually one of us wearing a sufficiently geeky T-shirt to make us slightly recognisable. See you tomorrow, Tom