[28841] in Perl-Users-Digest
Perl-Users Digest, Issue: 85 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 29 09:06:33 2007
Date: Mon, 29 Jan 2007 06:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 29 Jan 2007 Volume: 11 Number: 85
Today's topics:
Re: custom regexp modifiers <spamtrap@dot-app.org>
Re: custom regexp modifiers axel@white-eagle.invalid.uk
Re: custom regexp modifiers <bik.mido@tiscalinet.it>
Re: custom regexp modifiers <tadmc@augustmail.com>
Fwd: Re: problem GD and my package Random->Random::new <john.swilting@wanadoo.fr>
Re: help with mime head jcharth@hotmail.com
Re: how to flush a file <rvtol+news@isolution.nl>
Re: how to flush a file <bik.mido@tiscalinet.it>
HTML::TokeParser <xx@wp.pl>
Re: HTML::TokeParser <tadmc@augustmail.com>
Re: HTML::TokeParser <mritty@gmail.com>
new CPAN modules on Mon Jan 29 2007 (Randal Schwartz)
Re: socket and fork <m@remove.this.part.rtij.nl>
Re: socket and fork <dontmewithme@got.it>
Win32::OLE problem with iTunes SelectedPlaylist zf78ro002@sneakemail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 28 Jan 2007 14:18:15 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: custom regexp modifiers
Message-Id: <m2ac03gdu0.fsf@Sherm-Pendleys-Computer.local>
"Paul" <paul@probulletin.com> writes:
> I'll certainly do that in future
Do what?
> but I find it hard to believe that
> you can't figure out the context of my post when the previous post
> asks "why is it there?" and my reply begins "it shouldn't be there".
What if your previous post, or your reply, hasn't arrived at my server yet?
What if it never does? How do you believe I'm supposed to figure out the
context of your post then?
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Sun, 28 Jan 2007 20:38:19 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: custom regexp modifiers
Message-Id: <%Q7vh.3366$B_.403@newsfe06.phx>
Paul <paul@probulletin.com> wrote:
> I'll certainly do that in future, but I find it hard to believe that
> you can't figure out the context of my post when the previous post
> asks "why is it there?" and my reply begins "it shouldn't be there".
This post is the first one I read on the c.l.p.m group today. To figure
out the context means that I have to trawl back through previous posts
to establish that context - hardly a very productive use of time. It
becomes even worse when to make real sense one needs to compare what is
being commented on and the comment at the same time.
Moreover the concept of *the* previous post is a bit meaningless in
Usenet... any order based on time will vary between different servers
and how many contributions to a thread might have been made to a
particular thread in the meantime?
There is the concept of the article that you are following up to, but
many newsreaders do not make it easy to jump directly to this article
(which in any case may longer be available) and it can still mean having
to switch between two articles.
Axel
------------------------------
Date: Sun, 28 Jan 2007 23:08:46 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: custom regexp modifiers
Message-Id: <3e7qr2lb6jk96raupoqp6gfjvjh140f4u9@4ax.com>
On 28 Jan 2007 10:36:38 -0800, "Paul" <paul@probulletin.com> wrote:
>I'll certainly do that in future, but I find it hard to believe that
>you can't figure out the context of my post when the previous post
>asks "why is it there?" and my reply begins "it shouldn't be there".
No, I *do* figure it out. I *had* seen the post you were replying to.
But due to the very nature of USENET one can't rely on this to happen
all the time. In fact it's not that common, but it happens to receive
from one's newsserver replies to posts one hasn't got yet, if ever.
And even when this is not the case, one may not remember perfectly
well which thread a post is actually in, and a few lines of quoted
context easily add so much to clarity with virtually no effort.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sun, 28 Jan 2007 17:17:04 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: custom regexp modifiers
Message-Id: <slrnerqbng.94n.tadmc@tadmc30.august.net>
Paul <paul@probulletin.com> wrote:
> I find it hard to believe that
> you can't figure out the context of my post
That is because you do not understand how Usenet works.
(Google Groups is not Usenet and most participants here do not
view the group via Google Groups.)
Your reply may arrive *before* the post that you are replying too.
The post that you are replying to may *never* arrive.
Your post may be found as part of a web search (now that *is*
Google Groups) even years from now, in which case the reader
may have access to no other posts in the thread.
Many folks are often participating in many threads at once,
so context is extremely important to help them remember what
was said in this one.
But the reason that trumps all of them is that it is socially
unacceptable to not quote context on Usenet.
So you either quote context or you take heat from your peers.
It's every poster's choice.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 29 Jan 2007 07:00:11 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Fwd: Re: problem GD and my package Random->Random::new :)
Message-Id: <45bd8d59$0$5082$ba4acef3@news.orange.fr>
I obtain a small image
i recopied the pod
But the rectangle does not see itself any more
how to make :)
i send the mail at sam
en français
j'obtiens une petie image
j'ai recopie le pod
mais le rectangle ne se voit plus
comment faire
my code:
#!/usr/bin/perl -w
use strict;
use diagnostics;
use CGI;
use CGI::Carp;
use GD;
use GD::Text::Wrap;
require "Random.pm";
my $q = new CGI;
my $gd = GD::Image->new(100,100);
my $white = $gd->colorAllocate(255,255,255);
my $black = $gd->colorAllocate( 0, 0, 0);
my $blue = $gd->colorAllocate(127,127,255);
my $red = $gd->colorAllocate(127, 0, 0);
my $text = Random->new();
my $wrapbox = GD::Text::Wrap->new( $gd,
line_space => 4,
color => $black,
text => $text,
);
$wrapbox->set_font(gdMediumBoldFont);
$wrapbox->set_font('arial',12);
$wrapbox->set(align => 'center', width => 100);
$wrapbox->draw(10,10);
$gd->rectangle($wrapbox->get_bounds(100,100),$red);
print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT ;
print $gd->png();
---------- Message transmis ----------
Subject: Re: problem GD and my package Random->Random::new
Date: lundi 22 janvier 2007 06:32
From: "john.swilting" <john.swilting@wanadoo.fr>
To: "john.swilting" <john.swilting@wanadoo.fr>
john.swilting wrote:
> john.swilting wrote:
>> A. Sinan Unur wrote:
>>> "Stan R." <stan@invalid.blz/hmrprint/com.com> wrote in news:ep0hcj0hp1
>>>
>>> @news2.newsguy.com:
>>>>> john.swilting wrote:
>>>
>>> ...
>>>
>>>>>> I am going to eat then to go to sleep me
>>>>>> I return tomorrow
>>>
>>> Good thing I plonked you today then.
>>>
>>>> my $random_obj = new Random;
>>>>
>>>> which can be more confortable for people who are used to C/C++/Java
>>>> grammar.
>>>
>>> Please read the section "Indirect Object Syntax" in perldoc perlobj
>>> before making such recommendations.
>>>
>>> Sinan
>>
>> I made one package
>> uses now $random = new Random
>>
>> code ok
>> compil nice
>> cgi its ok
>> thank you
>> I am going to change my customs
>> I am going to make package for the variables which owe exchanges to the
>> run my code
>> #!/use/bin/perl -w
>>
>> package Random;
>>
>> use strict;
>> require Exporter;
>>
>> use vars qw( @ISA);
>>
>> ##$VERSION = O.O1;
>>
>> @ISA = qw(Exporter);
>>
>> sub new {
>> my $class=shift;
>> my $self={};
>> bless $self,$class;
my@liste=('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15',
>>
>> '16','17','18','19','20','21','22','23','24','25','26','27','28',
>> '29','30','31','32','33','34','35','36','37','38','39','40','41',
>> '42','43','44','45','46','47','48','49','50','51','52','53','54',
>> '55','56','57','58','59','60','61','62','63','64','65','66','67',
>> '68','69','70','71','72','73','74','75','76','77','78','79','78',
>> '79','80','81','82','83','84','85','86','87','88','89','90','91',
>> '92','93','94','95','96','97','98','99','100','101','102','103',
>> '104','105','106','107','108','109','110');
>> $self="";
>> my$self1="";
>> my$self2="";
>> my$self3="";
>> my$self4="";
>> $self1.=$liste[int rand@liste];
>> $self .= $self1;
>> $self2.=$liste[int rand@liste];
>> $self .=$self2;
>> $self3.=$liste[int rand@liste];
>> $self .=$self3;
>> $self4.=$liste[int rand@liste];
>> return $self;
>> }
>>
>>
>> END {}
>> 1;
>
> The positions of the text
> Have to change and colours also
> I go it package is I believe better
I would like that the text is in the middle of the image
And what the text displays well in the middle of the rectangle of the middle
of the image
How to make
-------------------------------------------------------
------------------------------
Date: 28 Jan 2007 16:54:40 -0800
From: jcharth@hotmail.com
Subject: Re: help with mime head
Message-Id: <1170032080.888363.305370@k78g2000cwa.googlegroups.com>
Thanks michael, the problem was i was downloading the file using
as_string instead of content in lwp. i had some extra http headers.
On Jan 28, 1:04 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 28 Jan 2007 09:12:58 -0800, jcha...@hotmail.com wrote:
>
> >I tried using open my $fh but $head->get returns an empty string
> >everysingle time, if i print $message I see the full message.
>
> >open my $fh, '<', \$message or die "D'Oh! $!\n";
> > my $head = MIME::Head->read($fh);
>
> >$myTo = lc($head->get('To',0));Are things different if you save $message to a temporary file and
> parse that? I see no reason why they should, but just to be sure...
> oh, and I hope your perl is recent enough, but if it is not, I mean if
> it doesn't support open()ing scalars in memory, then I suppose it
> would just give you an error - either that or try to open a file with
> the name of the stringified reference for reading, which is unlikely
> to exist and would cause the program to die() anyway. I don't know for
> sure because I only have access to fairly recent perls. Other than
> this I can only quote myself:
>
> : Also, reading M::H's docs I see
> :
> : : Before reading further, you should see MIME::Tools to make sure that
> : : you understand where this module fits into the grand scheme of things.
> : : Go on, do it now. I'll wait.
>
> Did you do so?
>
> >On Jan 27, 10:31 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:[snip full quoted content]
>
> *Please* do not top-post. If you don't know what top-posting is, then
> google for it. It makes very hard for us to follow the discussion
> properly.
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sun, 28 Jan 2007 20:56:38 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: how to flush a file
Message-Id: <epj2u6.1ks.1@news.isolution.nl>
Abigail schreef:
> Dr.Ruud:
>> Data Cruncher:
>>> My process writes to the log file. I want to periodically flush
>>> it so that tail -f on the the log file shows the progress on a
>>> regular basis.
>>
>> This is from `perldoc -f select`:
>>
>> $oldfh = select(STDERR); $| = 1; select($oldfh);
>
> Well, that will flush STDERR but it has the effect of leaving it
> unbuffered. Which may not be what the OP wants.
OP wrote "periodically flush it", so you are right that leaving it
buffered in between can be what he wants.
> I'd write it as:
>
> my $old_fh = select STDERR; {local $| = 1;} select $old_fh;
Yes, that is a nice and safe way to do a (single) flush, and restore the
original autoflush-status.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 28 Jan 2007 23:32:54 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how to flush a file
Message-Id: <ip8qr2ts9ivpc4nk2rfion886if39pmh11@4ax.com>
On Sun, 28 Jan 2007 13:29:17 -0500, Uri Guttman <uri@stemsystems.com>
wrote:
> A> I have to say, flushing a filehandle in Perl is unintuitive, awkward
> A> and phrone to do it while doing unintended side-effects. And, amazingly,
> A> it only takes one line in C.
>
>that is because you (and the rest of this thread) are confusing
>autoflushing (setting $|) with actual flushing which can be done with
But he is *not*! Indeed he was the first one to point out the
difference and post a way to do actual flushing by means of $|.
>the flush call in IO::Handle. it used to be fflush in POSIX but that
>refers to IO::Handle now. so for older perls look for fflush in POSIX.
And he also wrote how to do the same with I::H. He's complaining
(well, sort of) about *having* to use the latter to do so in one
idiot-proof statement, while all other FH manipulations can be
performed quite easily also without it.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Mon, 29 Jan 2007 11:30:15 +0100
From: avlee <xx@wp.pl>
Subject: HTML::TokeParser
Message-Id: <op.tmwvgpc91sq83a@saturn>
Hello
I want to find tag "X" in which i later want to find all "Y" tags.
Is it possible to do using HTML::TokeParser ?
Right now i found only "X" tag:
my $parser =3D HTML::TokeParser->new(\$data);
my $tag =3D $parser->get_tag($X_tag);
How to force parser to search "Y" tags from this moment - but only insid=
e =
"X" tag ?
(not the whole document) ?
Maybe it's easier to create new parser which parse only "X" tag source =
code ? But how ?
Thanx
------------------------------
Date: Mon, 29 Jan 2007 06:03:59 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: HTML::TokeParser
Message-Id: <slrnerrolf.b73.tadmc@tadmc30.august.net>
avlee <xx@wp.pl> wrote:
> I want to find tag "X" in which i later want to find all "Y" tags.
> How to force parser to search "Y" tags from this moment - but only inside
> "X" tag ?
---------------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
use HTML::TokeParser;
use Data::Dumper;
my $data =<<ENDHTML;
<html><body>
<y find=nope>don't find me</y>
<x>
<y find=yep>DO find me</y>
<y find=yep>and me</y>
</x>
<y find=nope>don't find me either</y>
<x>
<y find=yep2>find me too</y>
</x>
</body></html>
ENDHTML
my $X_tag = 'x';
my $Y_tag = 'y';
my $parser = HTML::TokeParser->new(\$data);
while ( my $tag = $parser->get_tag($X_tag) ) {
while ( $tag->[0] ne "/$X_tag" ) {
$tag = $parser->get_tag("/$X_tag", $Y_tag);
print Dumper $tag;
}
print "----------\n";
}
---------------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Jan 2007 04:07:04 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: HTML::TokeParser
Message-Id: <1170072423.989530.288860@q2g2000cwa.googlegroups.com>
On Jan 29, 5:30 am, avlee <x...@wp.pl> wrote:
> Hello
>
> I want to find tag "X" in which i later want to find all "Y" tags.
> Is it possible to do using HTML::TokeParser ?
> Right now i found only "X" tag:
>
> my $parser = HTML::TokeParser->new(\$data);
> my $tag = $parser->get_tag($X_tag);
>
> How to force parser to search "Y" tags from this moment - but only inside
> "X" tag ?
> (not the whole document) ?
> Maybe it's easier to create new parser which parse only "X" tag source
> code ? But how ?
Once you've found your X tag, start a loop in which you find all tags
that are either Y or the end of X. If it's a Y, do what you need. If
it's the end of X, end your loop. Here's an example:
#!/usr/bin/env perl
use strict;
use warnings;
use HTML::TokeParser;
my $p = HTML::TokeParser->new(\*DATA);
while (my $token = $p->get_tag('h1')){
while (my $tag = $p->get_tag('b', '/h1')){
last if $tag->[0] eq '/h1';
my $bold_text = $p->get_text;
print "Found bold text: '$bold_text'\n";
}
}
__DATA__
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>This text <b> is bold</b> </h1>
<h2>So <b> is this </b>, but it shouldn't be found.</h2>
<h1><b>Many</b> bold <b>texts</b></h1>
</body>
</html>
Output:
Found bold text: ' is bold'
Found bold text: 'Many'
Found bold text: 'texts'
Hope that helps,
Paul Lalli
------------------------------
Date: Mon, 29 Jan 2007 05:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jan 29 2007
Message-Id: <JCM7u7.DpK@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Algorithm-MedianSelect-XS-0.17
http://search.cpan.org/~schubiger/Algorithm-MedianSelect-XS-0.17/
Median finding algorithm
----
DBIx-Class-HTMLWidget-0.09
http://search.cpan.org/~andremar/DBIx-Class-HTMLWidget-0.09/
Like FromForm but with DBIx::Class and HTML::Widget
----
Directory-Scratch-Structured-0.01
http://search.cpan.org/~nkh/Directory-Scratch-Structured-0.01/
creates temporary files and directories from a structured description
----
ExtUtils-InferConfig-0.01
http://search.cpan.org/~smueller/ExtUtils-InferConfig-0.01/
Infer Perl Configuration for non-running interpreters
----
Finance-QuoteTW-0.02
http://search.cpan.org/~alec/Finance-QuoteTW-0.02/
Fetch quotes of mutual funds in Taiwan
----
Graph-Easy-0.52
http://search.cpan.org/~tels/Graph-Easy-0.52/
Render graphs as ASCII, HTML, SVG or via Graphviz
----
Image-Pngslimmer-0.04
http://search.cpan.org/~acmcmen/Image-Pngslimmer-0.04/
slims (dynamically created) PNGs
----
Image-Pngslimmer-0.05
http://search.cpan.org/~acmcmen/Image-Pngslimmer-0.05/
slims (dynamically created) PNGs
----
Jifty-DBI-0.34
http://search.cpan.org/~jesse/Jifty-DBI-0.34/
An object-relational persistence framework
----
Lingua-Verbnet-1.002
http://search.cpan.org/~vkh/Lingua-Verbnet-1.002/
extract stats from verbnet xml files
----
Math-BigInt-1.78
http://search.cpan.org/~tels/Math-BigInt-1.78/
Arbitrary size integer/float math package
----
Math-BigInt-GMP-1.19
http://search.cpan.org/~tels/Math-BigInt-GMP-1.19/
Use the GMP library for Math::BigInt routines
----
Math-BigRat-0.16
http://search.cpan.org/~tels/Math-BigRat-0.16/
Arbitrary big rational numbers
----
Net-Appliance-Phrasebook-0.08
http://search.cpan.org/~oliver/Net-Appliance-Phrasebook-0.08/
Network appliance command-line phrasebook
----
Net-Appliance-Session-0.11
http://search.cpan.org/~oliver/Net-Appliance-Session-0.11/
Run command-line sessions to network appliances
----
Net-Appliance-Session-0.12
http://search.cpan.org/~oliver/Net-Appliance-Session-0.12/
Run command-line sessions to network appliances
----
Palm-KeyRing-0.90
http://search.cpan.org/~jv/Palm-KeyRing-0.90/
Interface to GNU KeyRing databases
----
Parse-Eyapp-1.06548
http://search.cpan.org/~casiano/Parse-Eyapp-1.06548/
Extensions for Parse::Yapp
----
PerlBuildSystem-0.43.290
http://search.cpan.org/~nkh/PerlBuildSystem-0.43.290/
Make replacement with rules written in perl.
----
Pod-POM-View-HTML-Filter-0.09
http://search.cpan.org/~book/Pod-POM-View-HTML-Filter-0.09/
Use filters on sections of your pod documents
----
SVN-Notify-Mirror-0.035
http://search.cpan.org/~jpeacock/SVN-Notify-Mirror-0.035/
Keep a mirrored working copy of a repository path
----
Tangram-2.10_01
http://search.cpan.org/~samv/Tangram-2.10_01/
Store pure objects in standard relational databases
----
Test-Pod-Snippets-0.02
http://search.cpan.org/~yanick/Test-Pod-Snippets-0.02/
Generate tests from pod code snippets
----
Text-MeCab-0.14
http://search.cpan.org/~dmaki/Text-MeCab-0.14/
----
Text-MeCab-0.15
http://search.cpan.org/~dmaki/Text-MeCab-0.15/
Alternate Interface To libmecab
----
Win32API-Registry-0.28
http://search.cpan.org/~blm/Win32API-Registry-0.28/
Low-level access to Win32 system API calls from WINREG.H
----
XML-RSS-Tools-0.20
http://search.cpan.org/~atrickett/XML-RSS-Tools-0.20/
A tool-kit providing a wrapper around a HTTP client, a RSS parser, and a XSLT engine.
----
bignum-0.18
http://search.cpan.org/~tels/bignum-0.18/
Transparent BigNumber support for Perl
----
dotReader-v0.0.11
http://search.cpan.org/~ewilhelm/dotReader-v0.0.11/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 28 Jan 2007 20:20:37 +0100
From: Martijn Lievaart <m@remove.this.part.rtij.nl>
Subject: Re: socket and fork
Message-Id: <pan.2007.01.28.19.20.37.752870@remove.this.part.rtij.nl>
On Sun, 28 Jan 2007 18:04:13 +0100, Larry wrote:
> Hello everybody,
>
> I don't know if this has been covered before, I'd love to code a
> tiny server that can hanlde several requests at the same...the following
> chuck of code can only handle one connection at a time:
(snip)
> How can I go about using fork() ? it's just a tiny server so a couple of
> connections at the same time would be good...
Did you look at perldoc perlipc? It's right in there.
HTH,
M4
--
Redundancy is a great way to introduce more single points of failure.
------------------------------
Date: Mon, 29 Jan 2007 14:01:55 +0100
From: Larry <dontmewithme@got.it>
Subject: Re: socket and fork
Message-Id: <dontmewithme-1A8208.14015529012007@news.tin.it>
In article <pan.2007.01.28.19.20.37.752870@remove.this.part.rtij.nl>,
Martijn Lievaart <m@remove.this.part.rtij.nl> wrote:
> Did you look at perldoc perlipc? It's right in there.
well, that's what I was looking for, still I have some difficulties
figuring out how fork() works. this is what I've got:
use POSIX ":sys_wait_h";
sub REAP {
1 until (-1 == waitpid(-1, WNOHANG));
$SIG{CHLD} = \&REAP;
}
$SIG{CHLD} = \&REAP;
die "can't fork: $!" unless defined( $pid = fork() );
if ($pid) {
# the if{} block runs only in the parent process
waitpid( $pid,0 );
} else {
# the else{} block runs only in the child process
exit(0)
}
how can I merge it with the following?
use Socket qw(:DEFAULT :crlf);
$socket = IO::Socket::INET->new() || die "unableto listen";
$socket->listen();
$| = 1;
while (1)
{
$client = $socket->accept;
if ($client)
{
...get data...send response...
close $client;
}
}
thanks
------------------------------
Date: Sun, 28 Jan 2007 21:29:44 -0500
From: zf78ro002@sneakemail.com
Subject: Win32::OLE problem with iTunes SelectedPlaylist
Message-Id: <0umqr29522t6klb9ktblkbaqf6uihmqp5g@4ax.com>
Hi,
I am trying to use the iTunes SDK to select a playlist in iTunes.
Needless to say, it isn't working :(
First, the relevant part of the documentation -- full docs here
http://developer.apple.com/sdk/itunescomsdk.html
-------
HRESULT IiTunes::CreatePlaylist ( [in] BSTR playlistName,
[out, retval] IITPlaylist ** iPlaylist
)
Creates a new playlist in the main library.
If playlistName is NULL or empty, the playlist will be created with a
default name.
Parameters:
playlistName The name of the new playlist (may be NULL or empty).
iPlaylist Returns an IITPlaylist object corresponding to the new
playlist.
Return values:
S_OK The operation was successful.
E_POINTER iPlaylist is NULL.
E_FAIL An unexpected error occurred.
-------
HRESULT IITBrowserWindow::SelectedPlaylist ( [in] VARIANT *
iPlaylist )
Sets the currently selected playlist in the Source list.
Parameters:
iPlaylist The playlist to select. This must be a VARIANT of type
VT_DISPATCH that points to an IITPlaylist.
Return values:
S_OK The operation was successful.
E_POINTER iPlaylist is NULL.
E_INVALIDARG iPlaylist is not the correct VARIANT type.
ITUNES_E_OBJECTDELETED The playlist has been deleted.
E_FAIL An unexpected error occurred.
-------
Here is the code I'm trying
===========================
use Win32::OLE;
# Create a new iTunes application object
$iTunes = new Win32::OLE("iTunes.Application", \&quit );
my $tmp_playlist = $iTunes->CreatePlaylist("Temporary Playlist $$");
# This confirms that $tmp_playlist is indeed an IITUserPlaylist
Object:
print Win32::OLE->QueryObjectType($tmp_playlist) . "\n";
my $variant = Win32::OLE::Variant->new(VT_DISPATCH|VT_BYREF,
$tmp_playlist);
# Neither one of these works...
$iTunes->BrowserWindow->{'SelectedPlaylist'} = $variant;
#$iTunes->BrowserWindow->SelectedPlaylist($variant);
# If it doesn't work, delete $tmp_playlist
if ( $iTunes->BrowserWindow->SelectedPlaylist->Name() ne
"Temporary Playlist $$" ) {
print "FAILED!\n";
$tmp_playlist->Delete();
}
quit;
sub quit
{
# This destroys the object (I hope)
undef $iTunes;
exit;
}
===========================
I'd appreciate any pointers you all might be able to provide.
BTW, if you've never written Perl scripts for iTunes, there are plenty
of examples here: http://teridon.googlepages.com/itunesscripts
TIA,
Rob
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 85
*************************************