develooper Front page | perl.perl5.porters | Postings from January 2001

followup to [ID 20001130.005] File::Glob in 5.6.0

From:
Marek Rouchal DAT CAD HW Tel 25849
Date:
January 9, 2001 00:49
Subject:
followup to [ID 20001130.005] File::Glob in 5.6.0
Message ID:
Pine.GSO.4.20.0101090928250.15410-100000@tamarix.hl.siemens.de
Dear all,

I was able to boil down the problem into a single script. I have the
impression that if the (internal) Perl compiler sees an instance of the
"glob" command *before* it encounters "use File::Glob;", then *subsequent*
instances of the "glob" command use the internal implementation of glob
instead of the one provided by File::Glob. Even worse, if I say "use
File::Glob qw(:glob)" or the like, I get "Bad realloc ignored" or even
segfaults. I feel this is an error, but maybe I'm wrong.

By the way, the difference between the two glob()s I see is on Solaris
when directories are protected by ACLs and seem unreadable from what
stat() returns. The File::Glob implementation does the right thing here.

I had the first reference to glob in an entirely different file and
package baefore, which was "use"d before the "use File::Glob", with the
same effects. It took quite a while to find the single glob "needle" in a
multi-thousand-line-haystack of modules ;-)

I saw this on perl-5.6.0 and 5.6.1-TRIAL1, compiled with Sun Workshop Pro
5.0 on Solaris 2.7 and 2.5.1 (Sparc).

Hope this helps,

Marek

Here is the script:

#!/opt/perl_5.6.1/bin/perl -w

# This test script outputs a list of files that match the given path.
# Problem: The list is incomplete, because the internal glob() is used
# instead of the one provided by File::Glob, despite the "use File::Glob"
# Background: The File::Glob implementation finds directories that are
# read/execute-enabled by ACLs and seem unreadable from what
# stat() returns.

use strict;

BEGIN {
  sub lala
  {
    # an early reference to glob, could be in an entirely different
    # package which is "use"d
    # comment it out and it works...
    glob('*');
  }
}

# ...or put this in front of the BEGIN block
use File::Glob;

# the "use" below instead of the above gives a 
#    Bad realloc() ignored at /opt/perl_5.6.1/lib/File/Glob.pm line 119.
#
#use File::Glob qw(:glob);

# some of the directories matched by the *'s are protected by ACLs.
# Although readable, the internal glob fails because it seems to look only
# at what stat() returns, not whether the directory can be opendir'ed. The
# File::Glob implementation does the right thing.
my @list = glob("/opt/libq/*/*/init/flow.def");

foreach(@list) {
  print "+$_+\n";
}




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About