[32763] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4027 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 6 11:09:43 2013

Date: Fri, 6 Sep 2013 08:09:02 -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, 6 Sep 2013     Volume: 11 Number: 4027

Today's topics:
        thread problem <dave@invalid.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 6 Sep 2013 13:27:46 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: thread problem
Message-Id: <fV45K0OBJxbE-pn2-FIfVXiZqy6dP@paddington.bear.den>

I am having a problem with threads on a Raspberry Pi. (Note - have 
never used threads in perl. Only C)

use strict;
use warnings;
use threads;
use threads::shared;
my $foo = 'foo';
threads->create({'void' => 1}, 'try');
sleep 2;
print "$foo - done\n";
sleep 5;
sub try
{
  threads->detach();
  $foo = 'bar';
  sleep 5;
  return;
}                          

Why isn't $foo changing in the main thread? I have tried passing $foo 
as an argument to try both as itself and as a scalar ref. No way can I
get $foo to change value in main.

What I am trying to do is use a thread to essentially tail a pipe and 
raise a flag in main if it sees a certain string appear.The main 
thread can't tail it because I don't want to block. So my "real* sub 
is:

sub get_title
{
  threads->detach();
  my $ref = shift;
  open my $FIFO, '<', '/home/pi/fifo_stdout' or die "Can't open 
fifo_stdout $!";

  while ( <$FIFO> )
  {
    if ( m{^StreamTitle='([^']*)'} )
    {
      $$ref = $1;
    }
  }
}                                                   
-- 
Regards
Dave Saville


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 4027
***************************************


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