[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Slurp weirdness



On Tue, Apr 25, 2000 at 04:26:43PM +0200, Paolo Campanella wrote:
> 
> Is there a leak/bug in glob()?
>     Due to the current implementation on some operating systems, when you
> use the glob() function or its angle-bracket alias in a scalar context,
> you may cause a leak and/or unpredictable behavior.

What is meant by a "leak"?  If the writer means that doing a glob() in
scalar context will spawn a process that may not exit immediately, the
writer is correct; the glob process will stick around until all the
available filenames have been read.  For example:

$foo = glob('*');
# The process for that glob is still active.

@bar = glob('*');
# The process for that glob has exited.

while ($qux = glob('*')) {
}
# The process for that glob has exited.
# (The process for the first glob is still active.)


I have no idea what the writer means by "unpredictable behavior".  More
details from the writer would have been helpful.  As far as I can tell, the
behavior is completely predictable; a glob process stays active until all
the files have been read.


> It's best therefore to use glob() only in list context.

Use the glob in whatever context you want, just be aware of the issues.


But, I don't think any of this applies for perl v5.6.0 compiled with
internal globbing.  :)


Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe