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

Re: [FWP] Slurp weirdness




The following came from the Perl FAQ a Day list (18 Apr 2000). I am
uncertain if they meant that the "unpredictable behaviour" only happens
if a glob is actually done, or which operating systems are affected
(would be nice if they said :-) ), but it may be related. I'm using
5.005_03 on Linux 2.2.5-15 i686.

-----------------------------------------------------------------------
Question:                                                                                                                                                   
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.
It's                                                                                       
    best therefore to use glob() only in list context.
-----------------------------------------------------------------------



Chip Turner wrote:
[snip]
> I don't think it is a bug in the /proc filesystem.  Just like many
> non-file descriptors that can be read with the read() system call, you
> aren't guaranteed that you will get the whole file in one read.
> Somewhat similar to a socket in that respect, I suppose.  It's
> probably better to think of /proc as more like reading from sockets,
> serial ports, or other non-file descriptors than reading from any old
> normal file.
> 
> Whether it's a bug in perl or not is arguable.  For safety I would
> slurp into an array context just to be sure.
> 
> Chip

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