[29455] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 699 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 30 14:10:26 2007

Date: Mon, 30 Jul 2007 11:09:09 -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           Mon, 30 Jul 2007     Volume: 11 Number: 699

Today's topics:
    Re: @arts <bik.mido@tiscalinet.it>
    Re: @arts <bik.mido@tiscalinet.it>
    Re: @arts <bik.mido@tiscalinet.it>
    Re: @arts <bik.mido@tiscalinet.it>
    Re: @arts <1usa@llenroc.ude.invalid>
    Re: fork command. <rajendra.prasad@in.bosch.com>
    Re: fork command. anno4000@radom.zrz.tu-berlin.de
    Re: fork command. <bik.mido@tiscalinet.it>
    Re: fork command. xhoster@gmail.com
    Re: fork command. <jgibson@mail.arc.nasa.gov>
    Re: form script question <glex_no-spam@qwest-spam-no.invalid>
    Re: getting arguments <bik.mido@tiscalinet.it>
    Re: Objects/Structures in Perl <olson_ord@yahoo.it>
    Re: Objects/Structures in Perl <olson_ord@yahoo.it>
        Perl CGI Oralce database error <tt1234_us@yahoo.com>
    Re: Perl CGI Oralce database error  sanantram@yahoo.com
    Re: Perl threads <zentara@highstream.net>
    Re: Perl threads  ivakras1@gmail.com
    Re: Perl threads xhoster@gmail.com
    Re: question on reference to array slice <bik.mido@tiscalinet.it>
        threads and logfile rotation <ThomasKratz@REMOVEwebCAPS.de>
        Using SQLServer Stored Procedure returns Data with DBI.  sharemania@gmail.com
    Re: Using SQLServer Stored Procedure returns Data with  <glex_no-spam@qwest-spam-no.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 30 Jul 2007 12:26:57 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <70fra31i5g5952matau6c612un0ms7l8gh@4ax.com>

On Sat, 28 Jul 2007 18:08:19 -0700, "Wade Ward" <zaxfuuq@invalid.net>
wrote:

>>>>  {
>>>>      my $i;
>>>>      sub i () : lvalue { $i }
>>>>  }
>>>How does this not have a name?
>>
>> What, precisely, doesn't have a name?
>I want to call the above a subroutine.  It doesn't have a label.  Apparently 

Yes, it is a subroutine. No, it doesn't have a label. Actually labels
are a whole another thing. I suppose you really mean name. But it does
have a name, precisely i. Just make the above

  sub withalongername () : lvalue { $i }

>it switches i for $i.  I spent a couple hours looking for another instance 

Well, not really: it's just a sub called i that returns as a lvalue (a
feature still deemed experimental) a variable called $i, defined in
the same lexical scope.

>of this in the literature without success.  Is this a subroutine?

Yes, it is a subroutine and I don't have idea in which literature did
you look it up, but you can find all the details in the obvious place:

  perldoc perlsub


HTH,
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, 30 Jul 2007 12:46:12 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <3bfra3h7uolgfcn9isdb37ld55sjnrh94a@4ax.com>

On Sun, 29 Jul 2007 03:26:47 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:

>to the rest of the program. However, subroutines don't have this 
>restriction. So, the subroutine called i is visible to the rest of the 

Plain old subroutines don't have it. Lexically scoped ones would,
except that they do not exist yet (not talking about anonymous
sub(ref)s assigned to a lexical variable, but about a C<my sub foo
{...}> thing) notwithstanding the fact that the lexical pad has had a
code slot for quite a lot of time. See also:

http://perlmonks.org/?node_id=489881

>Now, $i has gone out of scope, but i is a closure on $i, so $i has not 

Huh... I see that at risk of degenerating into a flame on whether it
is a closure or not. Actually I was of your same idea initially, then
I was eventually convinced of the opposite: the point being that while
in general, named closures can exist, in *Perl* closures are
implemented as anonymous subs.


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, 30 Jul 2007 12:51:05 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <legra31698n5ps1i2ebmk2ph82n7shva19@4ax.com>

On Sun, 29 Jul 2007 03:04:46 -0700, "Wade Ward" <zaxfuuq@invalid.net>
wrote:

>> This is all very silly. Aaaaanyway.
>To me, these are very interesting things.  When you routinely miss studying 

Yes interesting, but as the person whom you're replying to also wrote,
silly too.

>a given point in a new syntax, you study fundamental language concepts by 

No, these are *not* fundamental language concepts. The kind of
exercises shown here can be regarded as "advanced stuff".

>accident.  I'll have to try out these new directions for myself.  Thanks for 

Honestly, I suggest you do a favour to yourself and postpone them for
a later stage of your Perl-jitsu. It's really too early now.
Familiarize with *really* basic Perl stuff first.


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, 30 Jul 2007 12:52:59 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <kmgra3dn6hg14196klqbd8bgn3mqnsc71e@4ax.com>

On Mon, 30 Jul 2007 03:11:40 -0700, "Wade Ward" <zaxfuuq@invalid.net>
wrote:

>My compiler takes a puke on line 7, which is a use statement.  Does this not 
>mean that I need to install another module on my machine?

No you shouldn't. But then to know what's really going on, you should
show us... the puke. Are you sure you put the module in the same
directory as the script?


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, 30 Jul 2007 13:34:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: @arts
Message-Id: <Xns997D6165A5294asu1cornelledu@127.0.0.1>

"Wade Ward" <zaxfuuq@invalid.net> wrote in
news:3YSdnf_r4p6FoTHbnZ2dnUVZ_jqdnZ2d@comcast.com: 

> 
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message 
> news:Xns997BF3BADEEFasu1cornelledu@127.0.0.1...

 ...

>> C:\Home\asu1\Src\test> cat Clikei.pm
>> package Clikei;
>>
>> use strict;
>> use warnings;
>>
>> sub import {
>>    my $package = shift;
>>    my $export_to = caller;
>>
>>    for my $name ( @_ ) {
>>        my $sub_name = "${export_to}::${name}";
>>        {
>>            my $x;
>>            no strict 'refs';
>>            *{$sub_name} = sub () : lvalue { $x };
>>        }
>>    }
>> }
>>

 ...

>> This is all very silly. Aaaaanyway.

 ...

> To me, these are very interesting things.

Being silly and interesting are not mutually exclusive. Shoving mentos 
pieces in a 2 lt Diet Coke is also interesting yet very, very silly.

> When you routinely miss studying a given point in a new syntax, you 
> study fundamental language concepts by accident.

Don't do it by accident, do it by design.

Go step by step. Get the simple stuff right first: I.e. get this example 
to run on your computer.

> --
> Wade Ward 

You sig separator is incorrect it should be dash dash space newline. 
Yours is missing a space before the newline.

When you use a correct sig separator, newsreader software can 
automatically snip signatures.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



------------------------------

Date: Mon, 30 Jul 2007 17:12:06 +0530
From: "rajendra" <rajendra.prasad@in.bosch.com>
Subject: Re: fork command.
Message-Id: <f8kiqi$16h$1@news4.fe.internet.bosch.com>


If i want to update(modify) a in both child and parent process, how can I do
this?....
<anno4000@radom.zrz.tu-berlin.de> wrote in message
news:5h5mauF3j4vb7U2@mid.dfncis.de...
> rajendra <rajendra.prasad@in.bosch.com> wrote in comp.lang.perl.misc:
> > One more query:
> > Can I use a variable common to both child and parent process block?.
>
> You can.  Note that the same name addresses different variables in
> the parent and the child.  They will have the same initial value in
> both, but changes in one don't reflect in the other.
>
> Anno




------------------------------

Date: 30 Jul 2007 12:15:04 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: fork command.
Message-Id: <5h6328F3ih6m3U1@mid.dfncis.de>

rajendra <rajendra.prasad@in.bosch.com> wrote in comp.lang.perl.misc:
> <anno4000@radom.zrz.tu-berlin.de> wrote in message
> news:5h5mauF3j4vb7U2@mid.dfncis.de...
> > rajendra <rajendra.prasad@in.bosch.com> wrote in comp.lang.perl.misc:

Please don't top-post.  I have moved your additional question in
context.

> > > One more query:
> > > Can I use a variable common to both child and parent process block?.
> >
> > You can.  Note that the same name addresses different variables in
> > the parent and the child.  They will have the same initial value in
> > both, but changes in one don't reflect in the other.

> If i want to update(modify) a in both child and parent process, how can I do
> this?....

Supposing "a" should be "a variable".

You can't, at least not in the sense that you change a variable in one
process and have the corresponding variable in another process change as
well.  If processes need to exchange information you need some kind of
inter-process communication (IPC).  See "perldoc perlipc" for
possibilities.

An alternative would be to use threads, which do support shared
variables.  However, Perl threads are laden with problems, most
notably that many modules don't work with threads as they should.

Anno


------------------------------

Date: Mon, 30 Jul 2007 14:06:28 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: fork command.
Message-Id: <01lra39f1m7oln1soc2qkio456iak5qqji@4ax.com>

On Mon, 30 Jul 2007 17:12:06 +0530, "rajendra"
<rajendra.prasad@in.bosch.com> wrote:

>If i want to update(modify) a in both child and parent process, how can I do
>this?....

You must establys some sort of IPC between them. Read

  perldoc perlipc

to find out some ways to do so.


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: 30 Jul 2007 16:37:49 GMT
From: xhoster@gmail.com
Subject: Re: fork command.
Message-Id: <20070730123750.688$8n@newsreader.com>

"rajendra" <rajendra.prasad@in.bosch.com> wrote:
> <anno4000@radom.zrz.tu-berlin.de> wrote in message
> news:5h5mauF3j4vb7U2@mid.dfncis.de...
> > rajendra <rajendra.prasad@in.bosch.com> wrote in comp.lang.perl.misc:
> > > One more query:
> > > Can I use a variable common to both child and parent process block?.
> >
> > You can.  Note that the same name addresses different variables in
> > the parent and the child.  They will have the same initial value in
> > both, but changes in one don't reflect in the other.

> If i want to update(modify) a in both child and parent process, how can I
> do this?....

(top posting fixed, please don't top post.)

You can use forks::shared, or something like it.  Although it is generally
best to arrange things so you don't need to do what it is that you think
you want to do.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Mon, 30 Jul 2007 09:51:48 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: fork command.
Message-Id: <300720070951481414%jgibson@mail.arc.nasa.gov>

In article <f8k52o$icr$1@news4.fe.internet.bosch.com>, rajendra
<rajendra.prasad@in.bosch.com> wrote:

> One more query:
> Can I use a variable common to both child and parent process block?.
> "rajendra" <rajendra.prasad@in.bosch.com> wrote in message
> news:f89s46$i07$1@news4.fe.internet.bosch.com...
> > Hello All,
> > The perl documentation says the fork command generates two copies of the
> > program ,one parent and one child.
> > If this is correct,can this  fork command be used for multitasking?.

The most straight-forward way to do this is to use shared-memory, if
your platform supports it. However, doing so introduces some
complexity, such as race conditions and the possibility of inconsistent
data structures. Avoiding these problems requires the use of other OS
functions such as mutexes or semaphores, which have their own
complexity.

Perl supports shared memory, but I have not used it.

See 'perldoc perlipc' as already recommended by others.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


------------------------------

Date: Mon, 30 Jul 2007 11:47:36 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: form script question
Message-Id: <46ae1628$0$505$815e3792@news.qwest.net>

David Pyles wrote:
> I'm a web designer, but not a perl programmer.  I've been working on 
> some forms using the form mail program that is part of VDeck. 

Whatever that is...


> $vdeck->send_email({ -to      => $to,
>                    -from    => $to,
>                    -cc      => [split ',', $cc],
>                    -bcc     => [split ',', $bcc],
>                    -subject => "Feedback: from $form_meta->[2]",
>                    -message => $message
>                 });

> 
> Can someone tell me how to modify this script to make it pick-up the 
> value of a hidden "subject" field in the form and place it's value in 
> the subject line of the resulting email?

        -subject => $q->param('name_of_hidden_subject_field'),

If $to is supplied via the form, then anyone can easily set it and use 
your site to send E-Mail to anyone.


------------------------------

Date: Mon, 30 Jul 2007 12:56:40 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: getting arguments
Message-Id: <augra3luarl1gu3b6hj2dvhv14asrlj8tg@4ax.com>

On Sat, 28 Jul 2007 17:07:22 -0400, Sherm Pendley
<spamtrap@dot-app.org> wrote:

>Sorry, this is "abuse" - "arguments" is down the hall on your left. :-)

Huh, sorry for being dense... is this the famous Monty Pyton's sketch?


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, 30 Jul 2007 10:32:33 -0700
From:  "O. Olson" <olson_ord@yahoo.it>
Subject: Re: Objects/Structures in Perl
Message-Id: <1185816753.531049.289930@22g2000hsm.googlegroups.com>

Thanks Sinan for sharing about yourself. I think I am much younger
than you - you seem to have studied longer than I have had years of my
life.

	I think that it is just my problem that I cannot remember. I was just
checking if you had some smarter solution :)
Thanks again,
O.O.



------------------------------

Date: Mon, 30 Jul 2007 10:34:32 -0700
From:  "O. Olson" <olson_ord@yahoo.it>
Subject: Re: Objects/Structures in Perl
Message-Id: <1185816872.493556.293700@22g2000hsm.googlegroups.com>

On Jul 29, 10:50 pm, "David Formosa (aka ? the Platypus)"
<dform...@usyd.edu.au> wrote:
> Unfortunitly in perl5 you can't do that.  The best you can do is the
> following.
>
> sub print_time ($) {
>   my $temp_time = shift;
>   print $temp_time;
>
> }

Thanks David.
	I am thinking I would start a new thread on this topic - after
reading up what the docs say.

Thanks again,
O.O.





------------------------------

Date: Mon, 30 Jul 2007 08:46:27 -0700
From:  David <tt1234_us@yahoo.com>
Subject: Perl CGI Oralce database error
Message-Id: <1185810387.942268.64570@22g2000hsm.googlegroups.com>

Hi,

     I need to access to an Oracle database in a cgi script and got an
error " ORA-12154: TNS:could not resolve the connect identifier
specified (DBD ERROR: OCIServerAttach)". The OS is winxp and perl
version is 5.8.8 from activestate. The connection works fine when
tested in command window but got the error when load from web browser.
The apache web server is used. Any help is highly appreciated.

    Thanks!

    Regards,

    David



------------------------------

Date: Mon, 30 Jul 2007 10:03:18 -0700
From:  sanantram@yahoo.com
Subject: Re: Perl CGI Oralce database error
Message-Id: <1185814998.950685.142490@l70g2000hse.googlegroups.com>

Check if the websrvr user  has access to the Oracle client directory
containing oracle config files (these end in .ora and contain the TNS
name of your oracle server).
On Jul 30, 11:46 am, David <tt1234...@yahoo.com> wrote:
> Hi,
>
>      I need to access to an Oracle database in a cgi script and got an
> error " ORA-12154: TNS:could not resolve the connect identifier
> specified (DBD ERROR: OCIServerAttach)". The OS is winxp and perl
> version is 5.8.8 from activestate. The connection works fine when
> tested in command window but got the error when load from web browser.
> The apache web server is used. Any help is highly appreciated.
>
>     Thanks!
>
>     Regards,
>
>     David




------------------------------

Date: Mon, 30 Jul 2007 07:11:18 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Perl threads
Message-Id: <0khra35h6b3asi63u3c2tmo1mhj9f11lhk@4ax.com>

On Mon, 30 Jul 2007 08:55:55 -0000, ivakras1@gmail.com wrote:

>Hi all!
>I have a perl threads question. Of cuz i have read perl threads
>tutorial and think its clear to me. But some questions...
>Q1: Is threads->create method only creates thread, but not runs theads
>until im join it (or detach)?

The thread starts running as soon as you create it. 

There are some simple rules. 
1. A thread, whether joinable or detached, MUST return, or reach the end
of it's code block, for it to terminate. That means you may need some
logic with shared variables, to signal a thread to return, if you want
to avoid the "a thread exited while x running" warning.  The warning
is harmless, unless the threads were doing something that needed a clean
finish. Joining by itself, WILL NOT terminate a thread, unless it has
returned first.

2. Use alot of shared variables to track and control your threads.

3. You have 2 ways to get return values from a thread. One is through
shared variables, and the other is through the return array.


#!/usr/bin/perl
use threads;

# join() does three things: it waits for a thread to exit,
# cleans up after it, and returns any data the thread may
# have produced. 

$thr1 = threads->new(\&sub1);
$ReturnData1 = $thr1->join;
print "Thread1 returned @$ReturnData1\n";

$thr2 = threads->new(\&sub2);
$ReturnData2 = $thr2->join;
print "Thread2 returned @$ReturnData2\n";

$thr3 = threads->new(\&sub3);
$ReturnData3 = $thr3->join;
print "Thread3 returned @$ReturnData3\n";


sub sub1 {
print "In thread1.....\n";
sleep 10;
@values = ('1a','1b', '1c');
return \@values; 
}

sub sub2 {
print "In thread2.....\n";
sleep 10;
@values = ('2a','2b', '2c');
return \@values; 
}

sub sub3 {
print "In thread3.....\n";
sleep 10;
@values = ('3a','3b', '3c');
return \@values; 
}
__END__

############################################
Some pseudo-code for terminating early:

#in main thread
my $die:shared = 0;
for( 1 .. 10 ){$thr = threads->new(\&thread_code);} 
 ...
 ...
if( $foobar ==42 ){ clean_exit()  }

sub clean_exit{
 $die =1;
 $_->join for threads->list();

}


#in thread
sub thread_code{
   for (1..10){
         if( $die == 1){return}
         print "$_\n";
         sleep 1; 
      }

print "I'm at the end of my code block, and ready to be joined\n";

}


zentara


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


------------------------------

Date: Mon, 30 Jul 2007 12:13:42 -0000
From:  ivakras1@gmail.com
Subject: Re: Perl threads
Message-Id: <1185797622.253230.306460@19g2000hsx.googlegroups.com>

Oh i see now... I can controll thread over shared vars. Ok.
In your example:
print "I'm at the end of my code block, and ready to be joined\n";
Is that mean thread waits to be joined or detached anyway? It never
dies by itself?

I need to fire up threads and forget about them, and continuing main
program, so i use detach. How can i count how much threads are running
now?
Tnx!



------------------------------

Date: 30 Jul 2007 17:08:02 GMT
From: xhoster@gmail.com
Subject: Re: Perl threads
Message-Id: <20070730130804.090$LG@newsreader.com>

ivakras1@gmail.com wrote:
> Hi all!
> I have a perl threads question. Of cuz i have read perl threads
> tutorial and think its clear to me. But some questions...
> Q1: Is threads->create method only creates thread, but not runs theads
> until im join it (or detach)?
> The folowing code and its output makes me think so:
> =====================
> ...


Using strict is probably even more important under threads than it
is without threads.  You should use strict.



> for (my $i=0;$i<=10;$i++)
> {
>            my $trl=threads->create(\&my_funct,$my_args);
>            if (@tc=threads->list){print "\t".@tc." threads running";}
> }
> ....
> if (@tc=threads->list)
> {
>           print "\nClosing threads: ";
>           while (@tc-1)
>           {
>                 @tc=threads->list;
>                  print @tc."  ";
>                  threads->list->join;
>           }
> }
> else
> {
>          exit(0);
> }
>
> ...
> sub my_funct
> {
>         $id=int(rand(1000));
>         setlogsock('unix'); #im using syslog to write a log file in /
> var/log/messages

Instead of putting in a comment telling us you are using syslog, you
should show us the code that actually "use"s syslog. (By which
you presumably mean Sys::Syslog?)  Is Sys::Syslog thread safe?


> Coments: i create 11 threads first, and than join them. Each thread
> waits for 0-5 (rand(5)) seconds, and than exits, writes a start time
> and a stop time in /var/log/messages via syslogd. It looks like thread-
> >create only creates the thread, not runs it. The output shoes it:
> threads->list increments every threads->create, but some of created
> threads would be done during this time,

The criteria for a thread to show up in list is not that it be "running"

From the doc:
       threads->list();
           This will return a list of all non joined, non
           detached threads.

So threads that are "finished" but still haven't been joined or detached
will be in the list.


 if i wrong!!! When i threads-
> >list->join one by one the threads seems to start, and threads->list
> starts decreasing! Can anybody answer me?

threads->list doesn't do what you think it does.


>
> Q2: threads->list returns a list of unjoind or undetached threads.

Er, OK, so you do know this.  Then why the confusion earlier?

> How
> to return a count of all threads, joined and detached both?? Then the
> main program exits while some child threads are still running
> (detached), perl warns me the count of running parentless threads. How
> can i get that count during main program still alive?!

The easy way is not to detach the threads.  Then, just before the parent
exits, run through threads->list and join all of them.  Or you could use
Thread::Running

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Mon, 30 Jul 2007 13:27:49 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: question on reference to array slice
Message-Id: <e3ira35be1nh2sk1nkqd4b32t5oum1h31i@4ax.com>

On Sun, 29 Jul 2007 18:04:28 -0000, Rick <rick.peng.du@gmail.com>
wrote:

>Subject: question on reference to array slice

Strictly speaking, you can't. But then you can by means of a "nasty
obscure hack":

  my @x=1..8
  sub refslice { \@_ }
  my $ref=refslice @x[2,3];

See <http://perlmonks.org/?node_id=618892> for more info.


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, 30 Jul 2007 18:56:40 +0200
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: threads and logfile rotation
Message-Id: <46ae1848$0$2626$bb690d87@news.main-rheiner.de>

I am a bit stumped with handling logfile rotation with a threaded app.
The below test script dies with "rename failed, Permission denied".
I assume this is because of the detached thread still referencing the 
filehandle because it got copied at thread creation.

Moving the thread creation before creation of the file solves this, but 
it is not really what I want. Ideally the thread should be able to log 
as well to the copied handle.

Is there a way around this?

(perl 5.88 under Win23 with threads 1.64)

TIA
Thomas

use strict;
use warnings;

use threads;
use IO::File;

my $fn = 'log/test.log';
my $fh = IO::File->new($fn, '>') or die "open failed, $!";
$fh->autoflush(1);

threads->new(sub { while(1) { sleep(1) } } )->detach();

my $i = 1;
my $j = 1;
while (1) {
     if ( $i % 10 == 0  ) {
         $fh->close()                  or die "close failed, $!";
         rename($fn, "$fn." . $j++)    or die "rename failed, $!";
         $fh = IO::File->new($fn, '>') or die "open failed, $!";
         $fh->autoflush(1);
     }
     print $fh "sequence: ", $i++, "\n";
     sleep(1);
}

-- 
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-


------------------------------

Date: Mon, 30 Jul 2007 13:03:05 -0000
From:  sharemania@gmail.com
Subject: Using SQLServer Stored Procedure returns Data with DBI...
Message-Id: <1185800585.796470.20970@22g2000hsm.googlegroups.com>

Hello,

I am trying to use stored Procedure in SQL Server with the DBi module,
and I am not getting the data that have been returned.

How should I do it?

Thanks.



------------------------------

Date: Mon, 30 Jul 2007 11:39:15 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Using SQLServer Stored Procedure returns Data with DBI...
Message-Id: <46ae1433$0$496$815e3792@news.qwest.net>

sharemania@gmail.com wrote:
> Hello,
> 
> I am trying to use stored Procedure in SQL Server with the DBi module,
> and I am not getting the data that have been returned.
> 
> How should I do it?

Show how you are trying to do it.


------------------------------

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 699
**************************************


home help back first fref pref prev next nref lref last post