[25841] in Perl-Users-Digest
Perl-Users Digest, Issue: 8077 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 13 14:05:17 2005
Date: Fri, 13 May 2005 11:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 13 May 2005 Volume: 10 Number: 8077
Today's topics:
Re: deamons and IPC (Anno Siegel)
remove a value from a callback array <usenet@NOSPAM.obantec.net>
Re: remove a value from a callback array xhoster@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 May 2005 10:24:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: deamons and IPC
Message-Id: <d61v8f$qab$1@mamenchi.zrz.TU-Berlin.DE>
Moritz Karbach <moritz.karbach@desy.de> wrote in comp.lang.perl.misc:
> > perldoc perlipc not only tells how to communicate with processes, but also
> > how to have a script automatically deamonize itself.
>
> Ok, I'm gonna check this again.
>
> > While tcp sockets
> > may be handy for remote control, if you just need to communicate with it
> > from a local shell, you could use a fifo (named pipe). Then you could
> > simply have the deamon script read the fifo, which you could echo or write
> > to like a regular file to feed it commands.
>
> In fact this is what I tried first. But I stuck because
>
> my $result = <FIFO>;
>
> waits until some other process writes into the pipe. This is why something
> simple like
>
> while(my $result = <FIFO>)
> {
> if ( $result=~m/stop/ )
> {
> exit;
> }
>
> system("./launch_this_every_second.sh");
>
> sleep 1;
> }
>
> doesn't work. Or am I missing something obvious?
You can open the pipe with sysopen() and use the O_NDELAY flag.
Then the pipe will not block, neither on open() nor on a read
attempt.
use Fcntl qw( O_RDONLY O_NDELAY);
my $fifo;
sysopen $fifo, $_, O_RDONLY | O_NDELAY or die "$_: $!" for '/tmp/pipe';
while( 1 ) {
if ( defined( my $result = <$fifo>) ) {
print "got $result";
last if $result =~ /stop/;
}
system( "echo Just my job, Sir"); sleep 1;
}
Anno
------------------------------
Date: Fri, 13 May 2005 16:18:22 +0100
From: "Mark D Smith" <usenet@NOSPAM.obantec.net>
Subject: remove a value from a callback array
Message-Id: <4284c4a2$0$2604$da0feed9@news.zen.co.uk>
Hi
i have a call-back which i need to check 1 array value and remove some of
the words used.
my $status =$content->{status};
fine gives 1 or 0 which i use but
$content->{names} is an array of words some of which i want to delete.
my $names =$content->{names}[0];
example $names = test1 test2 test3 wibble test4 in this instance i want to
remove wibble.
Mark
------------------------------
Date: 13 May 2005 15:35:27 GMT
From: xhoster@gmail.com
Subject: Re: remove a value from a callback array
Message-Id: <20050513113527.099$IE@newsreader.com>
"Mark D Smith" <usenet@NOSPAM.obantec.net> wrote:
> Hi
>
> i have a call-back which i need to check 1 array value and remove some of
> the words used.
I don't see any call-backs in your code.
> my $status =$content->{status};
>
> fine gives 1 or 0 which i use but
>
> $content->{names} is an array of words some of which i want to delete.
I assume you mean that $content->{names} is reference to an array of.....
Anyway, if want to delete words, it may make more sense for it to be
reference to a hash, rather than a reference to an array.
If you truly can't turn it into a hash, I guess I would do:
@{$content->{names}} = grep $_ ne $word_to_delete, @{$content->{names}};
or if you need to delete several words (stored in %words_to_delete):
@{$content->{names}} = grep not exists $words_to_delete{$_},
@{$content->{names}};
> my $names =$content->{names}[0];
This looks like Perl, although I don't understand what you intend by it.
> example $names = test1 test2 test3 wibble test4 in this instance i want
> to remove wibble.
This looks like neither Perl nor English, but some incomprehensible mismash
of the two. I have no idea what you are trying to say about $names.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
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 V10 Issue 8077
***************************************