Re: OT? Perl Question, iCal

2012-06-02 Thread Dirk Koopman

On 01/06/12 21:59, Simon Wistow wrote:

it's dog slow (fcvo 'dog')


I find my values of "dog" don't really apply (being Border Terriers), or 
are unhelpful in these circumstances.


Try: "snail on mogodon". Less variability and very, very slow.




Re: OT? Perl Question, iCal

2012-06-01 Thread Simon Wistow
On Tue, May 22, 2012 at 02:48:05PM +0100, Roger Burton West said:
> On Tue, May 22, 2012 at 03:35:51PM +0200, Nic Gibson wrote:
> >search.cpan.org gives me far too many results for iCal. I need to parse 
> >iCalendar (rfc 5545) files and then write them out as xCal (rfc 6321) files. 
> >Does anyone have a particular recommendation for a module? Writing the XML 
> >isn't the issue for me - it's more the parsing iCalendar files. Suggestions?
> 
> Date::ICal seems to get the basic job done. Data::ICal::DateTime is
> great but dog-slow (or perhaps it's my programming). Other opinions are
> probably at least as valid as mine.

I second Data::ICal - it's dead easy and it can read and generate. It 
uses Text::vFile underneath for parsing.

Data::ICal::DateTime basically just adds DateTime support in and, you're 
right, it's dog slow (fcvo 'dog'). It's mostly my programming rather 
than yours I suspect although also partly DateTime (correctness comes at 
a price) and also the overhead of working out recurring events and 
whatnot.




Re: OT? Perl Question, iCal

2012-05-31 Thread Simon Cozens

On 22/05/2012 22:35, Nic Gibson wrote:

search.cpan.org gives me far too many results for iCal.


Text::vFile is my weapon of choice for v-flavoured file formats, of which 
iCalendar is a variant.





Re: OT? Perl Question, iCal

2012-05-22 Thread David Cantrell
On Tue, May 22, 2012 at 03:35:51PM +0200, Nic Gibson wrote:

> search.cpan.org gives me far too many results for iCal. I need to parse 
> iCalendar (rfc 5545) files and then write them out as xCal (rfc 6321) files. 
> Does anyone have a particular recommendation for a module? Writing the XML 
> isn't the issue for me - it's more the parsing iCalendar files. Suggestions?

I was looking at something along these lines a few days ago, and gave up
in disgust at the documentation for everything iCal-ish.

Sorry, that's not very helpful is it.

-- 
David Cantrell | Enforcer, South London Linguistic Massive

Do not be afraid of cooking, as your ingredients will know and misbehave
   -- Fergus Henderson


Re: OT? Perl Question, iCal

2012-05-22 Thread Nic Gibson

On 22 May 2012, at 18:10, David Cantrell wrote:

> On Tue, May 22, 2012 at 03:35:51PM +0200, Nic Gibson wrote:
> 
>> search.cpan.org gives me far too many results for iCal. I need to parse 
>> iCalendar (rfc 5545) files and then write them out as xCal (rfc 6321) files. 
>> Does anyone have a particular recommendation for a module? Writing the XML 
>> isn't the issue for me - it's more the parsing iCalendar files. Suggestions?
> 
> I was looking at something along these lines a few days ago, and gave up
> in disgust at the documentation for everything iCal-ish.
> 
> Sorry, that's not very helpful is it.

I'm fairly glad you said it though. I was beginning to feel the same way. 

nic

> 
> -- 
> David Cantrell | Enforcer, South London Linguistic Massive
> 
> Do not be afraid of cooking, as your ingredients will know and misbehave
>   -- Fergus Henderson

--
Corbas Consulting / @CorbasLtd
Digital Publishing Consultancy and Training
http://www.corbas.co.uk, +44 (0)7718 906817/+44 (0)1273 930765  





Re: OT? Perl Question, iCal

2012-05-22 Thread Roger Burton West
On Tue, May 22, 2012 at 03:35:51PM +0200, Nic Gibson wrote:
>search.cpan.org gives me far too many results for iCal. I need to parse 
>iCalendar (rfc 5545) files and then write them out as xCal (rfc 6321) files. 
>Does anyone have a particular recommendation for a module? Writing the XML 
>isn't the issue for me - it's more the parsing iCalendar files. Suggestions?

Date::ICal seems to get the basic job done. Data::ICal::DateTime is
great but dog-slow (or perhaps it's my programming). Other opinions are
probably at least as valid as mine.

Roger


OT? Perl Question, iCal

2012-05-22 Thread Nic Gibson
This appears to be my first message to london.pm in four years or so. Ho hum.

search.cpan.org gives me far too many results for iCal. I need to parse 
iCalendar (rfc 5545) files and then write them out as xCal (rfc 6321) files. 
Does anyone have a particular recommendation for a module? Writing the XML 
isn't the issue for me - it's more the parsing iCalendar files. Suggestions?

cheers

nic
--
Corbas Consulting / @CorbasLtd
Digital Publishing Consultancy and Training
http://www.corbas.co.uk, +44 (0)7718 906817/+44 (0)1273 930765  





Re: OT perl question

2002-01-16 Thread Mike Jarvis

On Wed, 2002-01-16 at 07:03, Newton, Philip wrote:

> AFAIK, Apache manages to pass content along to the client as soon as it
> receives it from the CGI program, even on Win32.

Nope, at least not yet.  It's been going to be fixed in the next release
for quite a while.  

2.0 though.  Yep, it'll be fixed then,
 
-- 
mike





Re: OT perl question

2002-01-16 Thread Newton, Philip

Sam Vilain wrote:
> On Wed, 16 Jan 2002 09:20:49 +0100
> "Newton, Philip" <[EMAIL PROTECTED]> wrote:
> 
> > FYI, the Xitami web server (at least on Win32 systems) 
> > doesn't output any of the CGI's output to the client
> > until the CGI is done, so perhaps it implements CGI
> > with STDOUT directed to a file
> 
> I thought that was just "how pipes work" in DOS.

DOS, yes, but AFAIK Win32 has proper pipes. And this isn't something written
using a DOS extender, I'm assuming, but rather with the Win32 API.

AFAIK, Apache manages to pass content along to the client as soon as it
receives it from the CGI program, even on Win32.

Cheers,
Philip
-- 
Philip Newton <[EMAIL PROTECTED]>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.




Re: OT perl question

2002-01-16 Thread Sam Vilain

On Wed, 16 Jan 2002 09:20:49 +0100
"Newton, Philip" <[EMAIL PROTECTED]> wrote:

> FYI, the Xitami web server (at least on Win32 systems) doesn't output any of
> the CGI's output to the client until the CGI is done, so perhaps it
> implements CGI with STDOUT directed to a file, which it then reads -- in
> which case you couldn't even rely on dev & ino fields of stat(STDIN).

I thought that was just "how pipes work" in DOS.

Sam.




Re: OT perl question

2002-01-16 Thread Newton, Philip

Nicholas Clark wrote:
> Does a CGI always run with a socket as STDOUT?
> (in that running with a CGI-faked ENV as part of a pipe in a 
> cron job is going to look awfuly like being run from a web
> server)
> 
> Or will there be servers that run the CGI with the output to 
> a pipe and in turn pump that to the client?

I doubt the specification makes any mention of this.

FYI, the Xitami web server (at least on Win32 systems) doesn't output any of
the CGI's output to the client until the CGI is done, so perhaps it
implements CGI with STDOUT directed to a file, which it then reads -- in
which case you couldn't even rely on dev & ino fields of stat(STDIN).

Cheers,
Philip
-- 
Philip Newton <[EMAIL PROTECTED]>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.




Re: OT perl question

2002-01-15 Thread Nicholas Clark

On Tue, Jan 15, 2002 at 04:15:29PM +, [EMAIL PROTECTED] wrote:
> I'd be very surprised if you have a terminal in a cron job (which was
> one possibility from the original requirements above). You can
> probably also use POSIX::isatty() from perl but I haven't checked
> it in detail, or the -t file test, which checks if a filehandle is
> opened to a tty.

Does a CGI always run with a socket as STDOUT?
(in that running with a CGI-faked ENV as part of a pipe in a cron job is
going to look awfuly like being run from a web server)

Or will there be servers that run the CGI with the output to a pipe and in
turn pump that to the client?

Maybe this is all too complex for the purposes of original question.

Nicholas Clark
-- 
ENOJOB http://www.ccl4.org/~nick/CV.html




Re: OT perl question

2002-01-15 Thread Paul Makepeace

On Tue, Jan 15, 2002 at 05:27:45PM +, Dominic Mitchell wrote:
> nemesis <[EMAIL PROTECTED]> writes:
> > Thanks to everyone who helped.  I will dump all the $ENV variable see
> > what I can see in the different cases.
> 
> Alternatively, have a look at some of the test cgi scripts that come
> with apache.  I was far too lazy to actually write a CGI to find that
> one out.  :-)

Here's one I prepared earlier,

http://realprogrammers.com/cgi-bin/env.cgi
http://realprogrammers.com/cgi-bin/src.cgi?env.cgi (source)

..which provides a dump of the environment variables and allows you to
play with a variety of GET & POST queries.

N.B.: This script is running under mod_perl so you'll see MOD_PERL =>
mod_perl/1.26 and PERL_SEND_HEADER => On as well as GATEWAY_INTERFACE =>
CGI-Perl/1.1

HTH,
P




Re: OT perl question

2002-01-15 Thread Dominic Mitchell

nemesis <[EMAIL PROTECTED]> writes:
> Thanks to everyone who helped.  I will dump all the $ENV variable see
> what I can see in the different cases.

Alternatively, have a look at some of the test cgi scripts that come
with apache.  I was far too lazy to actually write a CGI to find that
one out.  :-)

-Dom

-- 
| Semantico: creators of major online resources  |
|   URL: http://www.semantico.com/   |
|   Tel: +44 (1273) 72   |
|   Address: 33 Bond St., Brighton, Sussex, BN1 1RD, UK. |




Re: OT perl question

2002-01-15 Thread Robin Houston

On Tue, Jan 15, 2002 at 04:06:40PM +, David Cantrell wrote:
> In C, you want isatty(3).  In perl, try stat()ing STDIN.

Or just use:

  if (-t) { ...}

Pretty unreliable though - what if you used it in a pipe?  I think the
environment is a better way to go. It's actually pretty useful that
you can then simulate "CGI mode" on the command line for testing.

 .robin.




Re: OT perl question

2002-01-15 Thread nemesis

Dominic Mitchell wrote:

> nemesis <[EMAIL PROTECTED]> writes:
> 
> 
>>Anyone know of a way of telling whether a perl script was called as a
>>CGI (via the apache webserver) or directly (as in as a cron script or
>>command line)?
>>
> 
> if (exists $ENV{SERVER_NAME}) {
> print "I'm a cgi (probably)\n";
> } else {
> print "I don't appear to be a cgi\n";
> }


Thanks to everyone who helped.  I will dump all the $ENV variable see 
what I can see in the different cases.

Will.





-- 
*claw claw* *fang*
*shred* *rip* *ad hominem* *slash*
(more attacks will require consultancy fees.)
  -Nix.





Re: OT perl question

2002-01-15 Thread David Cantrell

On Tue, Jan 15, 2002 at 03:26:42PM +, Struan Donald wrote:
> * at 15/01 15:21 + nemesis said:
> > Anyone know of a way of telling whether a perl script was called as a 
> > CGI (via the apache webserver) or directly (as in as a cron script or 
> > command line)?
> will be a whole load of exciting CGI type things in %ENV if it's a cgi
> call so you could test for those.

That may break if the environment happens to look like a CGI.  Which may, of
course, be what you want to happen.  A more reliable method would be to
detect whether you have a terminal or not.

In C, you want isatty(3).  In perl, try stat()ing STDIN.  My very quick
tests show me that the _rdev_ field changes from 34835 when STDIN is a
terminal to 0 when stdin is a pipe.  Don't rely on those numbers being
portable though.  There might be something on CPAN which wraps this up
all nice n' neat for you.

-- 
David Cantrell | [EMAIL PROTECTED] | http://www.cantrell.org.uk/david

  Some people, when confronted with a problem, think ``I know, I'll use
  regular expressions.'' Now they have two problems.-- jwz




Re: OT perl question

2002-01-15 Thread Dominic Mitchell

nemesis <[EMAIL PROTECTED]> writes:

> Anyone know of a way of telling whether a perl script was called as a
> CGI (via the apache webserver) or directly (as in as a cron script or
> command line)?

if (exists $ENV{SERVER_NAME}) {
print "I'm a cgi (probably)\n";
} else {
print "I don't appear to be a cgi\n";
}

-Dom

-- 
| Semantico: creators of major online resources  |
|   URL: http://www.semantico.com/   |
|   Tel: +44 (1273) 72   |
|   Address: 33 Bond St., Brighton, Sussex, BN1 1RD, UK. |




Re: OT perl question

2002-01-15 Thread Tommie M. Jones

use getpwnam to find out who the user is.


http://www.atlantageek.com
Get inside Atlanta's Tech scene

On Tue, 15 Jan 2002, nemesis wrote:

>
> Anyone know of a way of telling whether a perl script was called as a
> CGI (via the apache webserver) or directly (as in as a cron script or
> command line)?
>
> Will.
>
> --
> *claw claw* *fang*
> *shred* *rip* *ad hominem* *slash*
> (more attacks will require consultancy fees.)
>   -Nix.
>
>
>





Re: OT perl question

2002-01-15 Thread Struan Donald

* at 15/01 15:21 + nemesis said:
> 
> Anyone know of a way of telling whether a perl script was called as a 
> CGI (via the apache webserver) or directly (as in as a cron script or 
> command line)?

will be a whole load of exciting CGI type things in %ENV if it's a cgi
call so you could test for those.

s




Re: OT perl question

2002-01-15 Thread Chris Devers

On Tue, 15 Jan 2002, nemesis wrote:

> Anyone know of a way of telling whether a perl script was called as a
> CGI (via the apache webserver) or directly (as in as a cron script or
> command line)? 

Take a look at %ENV. I'm guessing that $ENV{'SERVER_NAME'} et al won't be
set when running as a cron job, but will be under cgi. Just try it out and
pick an environment variable that seems reliable; SERVER* seems likely to
me.

-- 
Chris Devers
sig here





OT perl question

2002-01-15 Thread nemesis


Anyone know of a way of telling whether a perl script was called as a 
CGI (via the apache webserver) or directly (as in as a cron script or 
command line)?

Will.

-- 
*claw claw* *fang*
*shred* *rip* *ad hominem* *slash*
(more attacks will require consultancy fees.)
  -Nix.