[26380] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8552 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 21 14:05:18 2005

Date: Fri, 21 Oct 2005 11:05:04 -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, 21 Oct 2005     Volume: 10 Number: 8552

Today's topics:
        Detecting the declaration of a variable? <bugbear@trim_papermule.co.uk_trim>
    Re: How to pass lock to the parent process? <h.b.furuseth@usit.uio.no>
    Re: How to pass lock to the parent process? xhoster@gmail.com
    Re: How to pass lock to the parent process? xhoster@gmail.com
    Re: why the perl docs suck <phaylon@dunkelheit.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 21 Oct 2005 11:18:46 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Detecting the declaration of a variable?
Message-Id: <4358c086$0$15056$ed2619ec@ptn-nntp-reader02.plus.net>

I recently had a nasty bug, where I typo'd a variable
name.

This meant that the variable that was defined and
had my value in it was not used.

Interestingly, my typo wasn't picked up
by "use strict", because one of the (many!)
Modules I'm using was declaring it
(name space pollution - ugh).

I found the problem by observation, and
binary chopping on the Modules I was using.

But.

Is there an easy way to find out where a variable
was declared/defined/exported?

What I'd like is a
   print declaration_scope($q);

    BugBear


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

Date: Fri, 21 Oct 2005 17:16:56 +0200
From: Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
Subject: Re: How to pass lock to the parent process?
Message-Id: <hbf.20051021ha5t@bombur.uio.no>

I wrote:
>xhoster@gmail.com writes:
>>Hallvard B Furuseth <h.b.furuseth@usit.uio.no> wrote:
>>> I need a to pass a file lock to the parent process - and
>>> to detect that this works.
>>
>> Why?  If the parent needs the lock, why not have the parent lock it?
>
> Well, that's another way.  But there are several children.  Each should
> start processing as soon as its lock can be acquired.  (...)

Oops, that was a fine example of a too-late-night posting:-)

The other half of the answer is that the client first does some work,
and after that it may need the lock for some more work.  After that it
may need to ask the parent to take over.

There are various ways to achieve that, but the simplest way - when
available - is for the child to create the lock and pass it to the
parent.

-- 
Hallvard


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

Date: 21 Oct 2005 16:38:15 GMT
From: xhoster@gmail.com
Subject: Re: How to pass lock to the parent process?
Message-Id: <20051021123815.243$v3@newsreader.com>

Hallvard B Furuseth <h.b.furuseth@usit.uio.no> wrote:
> xhoster@gmail.com writes:
> >Hallvard B Furuseth <h.b.furuseth@usit.uio.no> wrote:
> >> I need a to pass a file lock to the parent process - and
> >> to detect that this works.
> >
> > Why?  If the parent needs the lock, why not have the parent lock it?
>
> Well, that's another way.  But there are several children.  Each should
> start processing as soon as its lock can be acquired.  I don't want to
> need to go through the whole program to make it thread-safe, so the
> parent can just wait for one file lock at a time - at least if it uses
> flock().

You can use a non-blocking flock.  This would require a polling loop, but
it shouldn't be too bad.  It should be localizable to just one part of the
code, with little impact elsewhere.


Xho

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


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

Date: 21 Oct 2005 16:44:19 GMT
From: xhoster@gmail.com
Subject: Re: How to pass lock to the parent process?
Message-Id: <20051021124419.271$5X@newsreader.com>

Hallvard B Furuseth <h.b.furuseth@usit.uio.no> wrote:
> I need a to pass a file lock to the parent process - and
> to detect that this works.
>
> The best answer would be passing a file descriptor through a socket, but
> I couldn't find how to do that with Perl.

Have you looked at File::FDpasser?


> Another way is to open() the file in the parent and flock() it in the
> child - that works on my host, but I don't know how to test reliably if
> it works.  Perl can use either the C system call flock(), lockf() or
> fcntl() for file locks, and I don't even know if it is reliable for the
> flock() system call.

I'm not confident that any method is gauranteed to work across all these
variations.  Is your goal to have something that works for your system, and
it would be nice if it is portable?  Or is the goal to have something that
must be portable?

Xho

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


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

Date: 21 Oct 2005 11:53:56 GMT
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: why the perl docs suck
Message-Id: <4358d6d4$0$12655$9b4e6d93@newsread4.arcor-online.net>

Fred@fred.net <Fred@fred.net> wrote

> Ah, an educated man. He said that after, much later and after, the
> original writing.

I have the book at home, two times, including original hand-writing and
studied this terms for years. You may believe in what you like, but you
got Thelema a bit wrong.

93/93,
p

-- 
The first rule of project mayhem is: you do not ask questions.
                        -- Fight Club


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

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


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