Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard-dependent glob output, perl 5.8.0 on Solaris 8 #6303

Closed
p5pRT opened this issue Feb 12, 2003 · 4 comments
Closed

Wildcard-dependent glob output, perl 5.8.0 on Solaris 8 #6303

p5pRT opened this issue Feb 12, 2003 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 12, 2003

Migrated from rt.perl.org#20904 (status was 'resolved')

Searchable as RT20904$

@p5pRT
Copy link
Author

p5pRT commented Feb 12, 2003

From dshivak@metabolex.com

Summary​: glob returns initial argument string, only if no wildcards are
present in the glob argument. It happens in both scalar and list return
context.

TEST CODE​:
use Data​::Dumper; use strict;

my $noWildcard = "this_file_does_not_exist";
my $withWildcard = "file_does_not_exist_with_wildcard*";

globtest($noWildcard);
globtest($withWildcard);

sub globtest
{
my $filename = shift;
die if (-f $filename);
print "Testing glob using string '$filename'\n";
my @​array = glob($filename);
my $scalarvar = glob($filename);
print Dumper(\@​array);
print Dumper(\$scalarvar);
}

OUTPUT​:
Testing glob using string 'this_file_does_not_exist'
$VAR1 = [
  'this_file_does_not_exist'
  ];
$VAR1 = \'this_file_does_not_exist';
Testing glob using string 'file_does_not_exist_with_wildcard*'
$VAR1 = [];
$VAR1 = \undef;

PERL VERSION​:
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration​:
  Platform​:
  osname=solaris, osvers=2.8, archname=sun4-solaris
  uname='-----------'
  config_args=''
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='gcc', ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
  optimize='-O',
  cppflags='-fno-strict-aliasing'
  ccversion='', gccversion='3.2', gccosandvers='solaris2.8'
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='gcc', ldflags =' -L/usr/local/lib '
  libpth=/usr/local/lib /usr/lib /usr/ccs/lib
  libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
  perllibs=-lsocket -lnsl -ldl -lm -lc
  libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: USE_LARGE_FILES
  Built under solaris
  Compiled at Dec 11 2002 14​:42​:03
  @​INC​:
  /share/usr/local/lib/perl5/5.8.0/sun4-solaris
  /share/usr/local/lib/perl5/5.8.0
  /share/usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris
  /share/usr/local/lib/perl5/site_perl/5.8.0
  /share/usr/local/lib/perl5/site_perl/5.6.0
  /share/usr/local/lib/perl5/site_perl

@p5pRT
Copy link
Author

p5pRT commented Feb 13, 2003

From @hvds

"David Shivak" (via RT) <perlbug-followup@​perl.org> wrote​:
:Summary​: glob returns initial argument string, only if no wildcards are
:present in the glob argument. It happens in both scalar and list return
:context.

I think the problem here is one of documentation​: `perldoc -f glob`
refers one to File​::Glob which says that​:
  Since v5.6.0, Perl's CORE​::glob() is implemented in terms of bsd_glob().
.. but doesn't how it calls it. In fact, it calls the (undocumented)
File​::Glob​::csh_glob() instead, which does the extra argument parsing
described before calling the same internal routine as bsd_glob().

You are probably best off calling File​::Glob​::bsd_glob() directly,
with the particular set of flags appropriate to your needs.

An alternative is to load File​::Glob and set $File​::Glob​::DEFAULT_FLAGS
(also undocumented, I'm afraid) to your preferred set of GLOB_* flags,
and then use glob() in the usual way.

As far as I can see, the results you are seeing are as expected for
the default settings (GLOB_CSH along with GLOB_NOCASE on certain
systems, for historical reasons of csh compatibility).

Volunteers to improve the documentation are always welcome. :)

Hugo

@p5pRT
Copy link
Author

p5pRT commented Feb 13, 2003

From dshivak@metabolex.com

An alternative is to load File​::Glob and set
$File​::Glob​::DEFAULT_FLAGS
(also undocumented, I'm afraid) to your preferred set of GLOB_* flags,
and then use glob() in the usual way.

As far as I can see, the results you are seeing are as expected for
the default settings (GLOB_CSH along with GLOB_NOCASE on certain
systems, for historical reasons of csh compatibility).

Volunteers to improve the documentation are always welcome. :)

Hugo

Thanks for the informative and comprehensive reply! I'll take a look at
the documentation contribution process; if you have a direct hyperlink
to the cvs that would be appreciated. I agree, documentation is the
best place to address the expected but non-obvious output ;).

Dave Shivak

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant