Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.98k stars 559 forks source link

Bug in File::Find when options hash is used with find #7703

Closed p5pRT closed 19 years ago

p5pRT commented 19 years ago

Migrated from rt.perl.org#32993 (status was 'rejected')

Searchable as RT32993$

p5pRT commented 19 years ago

From kunkee@ugs.com

Created by kunkee@ugs.com

When I use find (File​::Find) with the options hash\, as illustrated in the code I have included here\, it fails on HP but works on Windows. The message I get is

  Not a subroutine reference at /usr/local/lib/perl5/5.00502/File/Find.pm line 197.

The script takes parameters\, but all you have to do is supply 3 junk file names that don't have to exist.

My HP is HP-UX \ B.11.00 E 9000/785 2012164768.

Here is the script​:

#!/usr/local/bin/perl # sub printusage {   print STDERR "Usage​: CompareGroups.pl [-d][-f][-h] \ \ \

...\n";   print STDERR "\n";   print STDERR "Where​:\n";   print STDERR " -d if present indicates that .diff files are to be produced\n";   print STDERR " for each file that is different. If -d is not specified\,\n";   print STDERR " all .diff files are left alone. If it is specified\, extra\n";   print STDERR " .diff files are deleted.\n";   print STDERR " -f if present indicates that .diff files are to be updated\n";   print STDERR " regardless of whether the .diff file seems to be up to date.\n";   print STDERR " -f implies -d.\n";   print STDERR " -h if present indicates that the usage message is to be printed.\n";   print STDERR " Any other option or input is ignored.\n";   print STDERR " \ is the first group to compare\, usually '.'.\n";   print STDERR " \ is the second group to compare\n";   print STDERR " \ ... is the list of directories within each group to compare\n"; }

use Cwd; use Getopt​::Std; use File​::Find; use File​::Spec;

getopts("fdh");

printusage()\, exit if $Getopt​::Std​::opt_h;

my $force = $Getopt​::Std​::opt_f; my $do_diffs = $Getopt​::Std​::opt_d;

$do_diffs = 1 if $force;

if (scalar @​ARGV \< 3) {   printusage();   exit; }

$group1 = shift @​ARGV; $group2 = shift @​ARGV; @​dirs = @​ARGV;

$curdir = getcwd();

@​foundfiles;

sub list_func {   push(@​foundfiles\, $File​::Find​::name) if (-f $$File​::Find​::name) && ! /history$/; }

%findoptions = ( wanted => list_func\, no_chdir => "1" );

chdir $group1; find(\%findoptions\, @​dirs); @​group1files = @​foundfiles; @​foundfiles = (); @​group1files = sort @​group1files;

chdir $curdir;

chdir $group2; find(\%findoptions\, @​dirs); @​group2files = @​foundfiles; @​foundfiles = (); @​group2files = sort @​group2files;

chdir $curdir;

sub uniq_u {   $input = shift;   $output = shift;   $previous = "";   $count = 0;   foreach (@​{$input})   {   if ($_ ne $previous)   {   push @​{$output}\, $previous if $count == 1;   $count = 1;   $previous = $_;   }   else   {   $count++;   }   }   push @​{$output}\, $previous if $count == 1; }

sub uniq_d {   $input = shift;   $output = shift;   $previous = "";   $count = 0;   foreach (@​{$input})   {   if ($_ ne $previous)   {   push @​{$output}\, $previous if $count > 1;   $count = 1;   $previous = $_;   }   else   {   $count++;   }   }   push @​{$output}\, $previous if $count > 1; }

push @​notingroup1filesx\, @​group1files; push @​notingroup1filesx\, @​group1files; push @​notingroup1filesx\, @​group2files; @​notingroup1filesx = sort @​notingroup1filesx; uniq_u(\@​notingroup1filesx\, \@​notingroup1files); open FILE\, ">notingroup1.files"; print FILE @​notingroup1files; close FILE;

push @​notingroup2filesx\, @​group1files; push @​notingroup2filesx\, @​group2files; push @​notingroup2filesx\, @​group2files; @​notingroup2filesx = sort @​notingroup2filesx; uniq_u(\@​notingroup2filesx\, \@​notingroup2files); open FILE\, ">notingroup2.files"; print FILE @​notingroup2files; close FILE;

print STDERR "notingroup1.files has the files in group 2 but not in group 1\n"; print STDERR "notingroup2.files has the files in group 1 but not in group 2\n";

@​inbothgroupsx = @​group1files; push @​inbothgroupsx\, @​group2files; @​inbothgroupsx = sort @​inbothgroupsx; uniq_d(\@​inbothgroupsx\, \@​inbothgroups);

foreach $file (@​inbothgroups) {   chomp $file;   ($fname) = ($file =~ /(\w+\.\w+)$/);

  # Decide if the file's diff needs to be updated   my ($f1date\, $f2date\, $dfdate);   $infile1 = File​::Spec->catfile($group1\, $file);   $infile2 = File​::Spec->catfile($group2\, $file);   @​f1date = stat("$infile1");   $f1date[9] = 0 if ! scalar @​f1date;   @​f2date = stat("$infile2");   $f2date[9] = 0 if ! scalar @​f2date;   @​dfdate = stat("$fname.diff");   $dfdate[9] = 0 if ! scalar @​dfdate;   next if ! $force && $f1date[9] \< $dfdate[9] && $f2date[9] \< $dfdate[9];   if ($ENV{PLAT} eq "wnti32")   {   $infile1 =~ s!/!\\!g;   $infile2 =~ s!/!\\!g;   @​diffs = `fc $infile1 $infile2`;   @​diffs = () if $diffs[0] =~ /no differences encountered/;   if ($diffs[0] =~ /^Invalid/)   {   print @​diffs;   die "bad diff return\n"   }   @​parts = split /\s+/\, $diffs[0];   $file1 = $parts[2];   $file2 = $parts[4];   shift @​diffs;   $current = "";   @​newdiff = ();   foreach (@​diffs)   {   if (substr($_\,0\,1) eq "*")   {   ($x\, $y) = split;   $current = "";   if ($y eq $file1)   {   $current = "\< ";   @​partdiff1 = ();   $partdiff = \@​partdiff1;   push @​partdiff1\, $_;   }   elsif ($y eq $file2)   {   $current = "> ";   @​partdiff2 = ();   $partdiff = \@​partdiff2;   push @​partdiff2\, $_;   }   else   {   if (substr($partdiff1[1]\,2) eq substr($partdiff2[1]\,2))   {   splice(@​partdiff1\, 1\, 1);   splice(@​partdiff2\, 1\, 1);   }   if (substr($partdiff1[$#partdiff1]\,2) eq substr($partdiff2[$#partdiff2]\,2))   {   $#partdiff1--;   $#partdiff2--;   }   push @​newdiff\, @​partdiff1;   push @​newdiff\, @​partdiff2;   push @​newdiff\, $_;   }   }   else   {   push @​{$partdiff}\, $current . $_;   }   }   @​diffs = @​newdiff;   }   else   {   @​diffs = `diff $infile1 $infile2`;   }

  $ltcount = scalar grep /^\< /\, @​diffs;   $gtcount = scalar grep /^> /\, @​diffs;   $stcount = scalar grep /OM\+\+ Scripted changes/\, @​diffs;   if ($ltcount + $gtcount != $stcount)   {   print "$file\n";   if ($do_diffs)   {   open DIFF\, ">$fname.diff";   print DIFF @​diffs;   close DIFF;   }   }   else   {   unlink "$fname.diff" if $do_diffs;   } }

Perl Info ``` Flags: category=utilities severity=medium Site configuration information for perl v5.8.0: Configured by pabiadzi at Thu Jun 19 14:16:53 PDT 2003. Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=hpux, osvers=11.00, archname=hpp-thread-multi uname='hp-ux cyhprt23 b.11.00 e 9000785 2008795644 8-user license ' config_args='-Dmksymlinks -Ud_sigsetjmp -Dusethreads -Duseithreads -Ulocincpth -Uloclibpth -Duselargefiles -Darchname=hpp -Uversion -Dprefix=/ips/udu4/tools/perl -Uinstallusrbinperl -Dbin=/ips/udu4/tools/perl/bin/hpp -Dscriptbin=/ips/udu4/tools/perl/bin -Dbin=/ips/udu4/tools/perl/bin/hpp -Dscriptbin=/ips/udu4/tools/perl/bin -Dsitebin=/ips/udu4/tools/perl/bin/hpp -Dsitescriptbin=/ips/udu4/tools/perl/bin -Dsitelib=/ips/udu4/tools/perl/site/lib -Dsitearch=/ips/udu4/tools/perl/site/lib/hpp -Darchlib=/ips/udu4/tools/perl/lib/hpp -Dprivlib=/ips/udu4/tools/perl/lib -des' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags =' -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ', optimize='+O2 +Onolimit', cppflags='-Aa -D__STDC_EXT__ -D_HPUX_SOURCE -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings' ccversion='A.11.01.21505.GP', gccversion='', gccosandvers='' 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='/usr/bin/ld', ldflags ='' libpth=/lib /usr/lib /usr/ccs/lib /usr/local/lib libs=-lnsl -lnm -lndbm -lmalloc -ldld -lm -lndir -lcrypt -lsec -lpthread -lc perllibs=-lnsl -lnm -lmalloc -ldld -lm -lndir -lcrypt -lsec -lpthread -lc libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred ' cccdlflags='+Z', lddlflags='-b +vnocompatwarnings' Locally applied patches: ACTIVEPERL_LOCAL_PATCHES_ENTRY @INC for perl v5.8.0: /ips/udu4/tools/perl/lib/hpp /ips/udu4/tools/perl/lib /ips/udu4/tools/perl/site/lib/hpp /ips/udu4/tools/perl/site/lib /ips/udu4/tools/perl/site/lib . Environment for perl v5.8.0: HOME=/users/kunkee LANG=C LANGUAGE (unset) LD_LIBRARY_PATH=/ntap/psa_data/arch/omxx_kunkee/workproj/hpp/lib:/ntap/psa_data/arch/omxx_kunkee/hpp/lib:/ntap/ips/ugnx40/ip3/hpp/lib:/ntap/ips/ugnx40/ip3/hpp/kits/ugii:/ntap/ips/ugnx40/ip3/NX/dbin/hpp:/ntap/ips/udu4/tools/lib/hpp LOGDIR (unset) PATH=.:/users/kunkee/bin:/ntap/ips/ugnx40/ip3/dbin/hpp:/ntap/ips/ugnx40/ip3/NX/dbin/hpp:/ntap/ips/ugnx40/ip3/dbin/unx:/ntap/ips/ugnx40/ip3/NX/dbin/unx:/ntap/ips/ugnx40/ip3/dbin:/ntap/ips/ugnx40/ip3/NX/dbin:/ntap/ips/ugnx40/ip3/p4cms:/ntap/ips/ugnx40/ip3/dbin/athena:/ntap/ips/ugnx40/ip3/dbin/omxx:/ntap/ips/udu4/tools/lib/hpp:/ntap/ips/udu4/tools:/ntap/ips/udu4/tools/bin/unx:/ips/udu4/tools/bin/unx/../../perl/bin/hpp:/bin:/usr/bin:/usr/dt/bin:/usr/bin/X11:/opt/ansic/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/hpnpl//bin:/opt/nettladm/bin:/opt/fc/bin:/opt/fcms/bin:/opt/upgrade/bin:/opt/aCC/bin:/usr/contrib/bin/X11:/opt/langtools/bin:/opt/pd/bin:/opt/graphics/phigs/bin:/opt/hparray/bin:/opt/graphics/common/bin:/opt/imake/bin:/etc:/usr/local/bin:/ntap/psa_data/arch/omxx_kunkee/workproj/pre_src/scripts:/ntap/psa_data/arch/omxx_kunkee/pre_src/scripts PERL5LIB_SAV= PERL_BADLANG (unset) PERL_SAV= SHELL=/bin/ksh ```
p5pRT commented 19 years ago

From kunkee@ugs.com

I just noticed that my program contains the bareword 'list_func' for the value of 'wanted'. I have tried '&list_func' and '\&list_func'\, and the all give the same error. What's in the script I sent is just the last thing I tried. I suppose I could have an error in how my program is constructed (using '\&list_func')\, but I have reviewed the documentation and if I have an error I don't see it. Besides\, it works on Windows.

I do have a workaround.

Steve

Here is the Windows configuration data​:

X​:\local\ugnx40\omxx2>perl -V

Summary of my perl5 (revision 5 version 8 subversion 0) configuration​:

  Platform​:

  osname=MSWin32\, osvers=4.0\, archname=MSWin32-x86-multi-thread

  uname=''

  config_args='undef'

  hint=recommended\, useposix=true\, d_sigaction=undef

  usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define

  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef

  use64bitint=undef use64bitall=undef uselongdouble=undef

  usemymalloc=n\, bincompat5005=undef

  Compiler​:

  cc='cl'\, ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DE

S_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX'\,

  optimize='-MD -Zi -DNDEBUG -O1'\,

  cppflags='-DWIN32'

  ccversion=''\, gccversion=''\, gccosandvers=''

  intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234

  d_longlong=undef\, longlongsize=8\, d_longdbl=define\, longdblsize=10

  ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='__int64'\, lseeksize=8

  alignbytes=8\, prototype=define

  Linker and Libraries​:

  ld='link'\, ldflags ='-nologo -nodefaultlib -debug -opt​:ref\,icf -libpath​:"w​:\alex\perl\build_perl\install\.TheInstallScriptWasNotRunTheI nstallScriptWasNotRunTheInstallScriptWasNotRun-perl\lib\MSWi

n32-x86-multi-thread\CORE" -machine​:x86'

  libpth="C​:\Program Files\Microsoft Visual Studio .NET\VC7\lib"

  libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib sh

ell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib

  perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib

  libc=msvcrt.lib\, so=dll\, useshrplib=yes\, libperl=perl58.lib

  gnulibc_version='undef'

  Dynamic Linking​:

  dlsrc=dl_win32.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' '

  cccdlflags=' '\, lddlflags='-dll -nologo -nodefaultlib -debug -opt​:ref\,icf -libpath​:"w​:\alex\per

l\build_perl\install\.TheInstallScriptWasNotRunTheInstallScriptWasNotRun TheInstallScriptWasNotRun-perl\lib\MSWin32-x86-multi-thread\CORE" -machine​:x86'

Characteristics of this binary (from libperl)​:

  Compile-time options​: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS

  Locally applied patches​:

  ActivePerl Build 806

  Built under MSWin32

  Compiled at Jun 19 2003 16​:19​:14

  @​INC​:

  C​:/Apps/UDU4/tools/perl/lib/MSWin32-x86-multi-thread

  C​:/Apps/UDU4/tools/perl/lib

  .

p5pRT commented 19 years ago

From @smpeters

[kunkee@​ugs.com - Fri Dec 10 10​:06​:08 2004]​:

This is a bug report for perl from kunkee@​ugs.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.

----------------------------------------------------------------- [Please enter your report here] When I use find (File​::Find) with the options hash\, as illustrated in the code I have included here\, it fails on HP but works on Windows. The message I get is

Not a subroutine reference at

/usr/local/lib/perl5/5.00502/File/Find.pm line 197.

The Perl you are using at /usr/local/bin/perl is a very old Perl. It did not take an options hash reference as an argument. It would only take a subroutine reference for the first argument to find(). Instead\, please try again using the Perl running the perlbug program. This is not a bug in Perl.

p5pRT commented 19 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 19 years ago

@smpeters - Status changed from 'open' to 'rejected'

p5pRT commented 19 years ago

From kunkee@ugs.com

Steve\, I would not have thought anyone would consider 5.8.0 'very' old compared to 5.8.6. But anyway... I checked the version of the perl documentation\, and it clearly identifies itself as 5.8.0. Here is a piece of the doc page on find​: File​::Find(3) perl v5.8.0 File​::Find(3) User Contributed Perl Documentation User Contributed Perl Documentation

  2003-06-19

NAME   File​::Find - Traverse a directory tree.

SYNOPSIS   use File​::Find;   find(\&wanted\, @​directories_to_search);   sub wanted { ... }

  use File​::Find;   finddepth(\&wanted\, @​directories_to_search);   sub wanted { ... }

  use File​::Find;   find({ wanted => \&process\, follow => 1 }\, '.');

DESCRIPTION   These are functions for searching through directory trees doing work   on each file found similar to the Unix find command. File​::Find   exports two functions\, "find" and "finddepth". They work similarly   but have subtle differences.

  find   find(\&wanted\, @​directories);   find(\%options\, @​directories);

As you can see\, it is 5.8.0 and it shows a hash for the first argument. We use the same version on Windows\, AND THE OPTION HASH WORKS THERE!!! I say it is a bug. Steve

-----Original Message----- From​: Steve Peters via RT [mailto​:perlbug-followup@​perl.org] Sent​: Friday\, December 10\, 2004 1​:54 PM To​: Kunkee\, Steve Subject​: [perl #32993] Bug in File​::Find when options hash is used with find

[kunkee@​ugs.com - Fri Dec 10 10​:06​:08 2004]​:

This is a bug report for perl from kunkee@​ugs.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.

----------------------------------------------------------------- [Please enter your report here] When I use find (File​::Find) with the options hash\, as illustrated in the code I have included here\, it fails on HP but works on Windows. The message I get is

Not a subroutine reference at

/usr/local/lib/perl5/5.00502/File/Find.pm line 197.

The Perl you are using at /usr/local/bin/perl is a very old Perl. It did not take an options hash reference as an argument. It would only take a subroutine reference for the first argument to find(). Instead\, please try again using the Perl running the perlbug program. This is not a bug in Perl.

p5pRT commented 19 years ago

From @smpeters

On Fri\, Dec 10\, 2004 at 02​:15​:03PM -0600\, Kunkee\, Steve wrote​:

Steve\, I would not have thought anyone would consider 5.8.0 'very' old compared to 5.8.6. But anyway... I checked the version of the perl documentation\, and it clearly identifies itself as 5.8.0. Here is a piece of the doc page on find​: File​::Find(3) perl v5.8.0 File​::Find(3) User Contributed Perl Documentation User Contributed Perl Documentation

                             2003\-06\-19

NAME File​::Find - Traverse a directory tree.

SYNOPSIS use File​::Find; find(\&wanted\, @​directories_to_search); sub wanted { ... }

      use File&#8203;::Find;
      finddepth\(\\&wanted\, @&#8203;directories\_to\_search\);
      sub wanted \{ \.\.\. \}

      use File&#8203;::Find;
      find\(\{ wanted => \\&process\, follow => 1 \}\, '\.'\);

DESCRIPTION These are functions for searching through directory trees doing work on each file found similar to the Unix find command. File​::Find exports two functions\, "find" and "finddepth". They work similarly but have subtle differences.

  find
        find\(\\&wanted\,  @&#8203;directories\);
        find\(\\%options\, @&#8203;directories\);

As you can see\, it is 5.8.0 and it shows a hash for the first argument. We use the same version on Windows\, AND THE OPTION HASH WORKS THERE!!! I say it is a bug. Steve

-----Original Message----- From​: Steve Peters via RT [mailto​:perlbug-followup@​perl.org] Sent​: Friday\, December 10\, 2004 1​:54 PM To​: Kunkee\, Steve Subject​: [perl #32993] Bug in File​::Find when options hash is used with find

[kunkee@​ugs.com - Fri Dec 10 10​:06​:08 2004]​:

This is a bug report for perl from kunkee@​ugs.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.

----------------------------------------------------------------- [Please enter your report here] When I use find (File​::Find) with the options hash\, as illustrated in the code I have included here\, it fails on HP but works on Windows. The message I get is

Not a subroutine reference at

/usr/local/lib/perl5/5.00502/File/Find.pm line 197.

The Perl you are using at /usr/local/bin/perl is a very old Perl. It did not take an options hash reference as an argument. It would only take a subroutine reference for the first argument to find(). Instead\, please try again using the Perl running the perlbug program. This is not a bug in Perl.

If you look closer at the path\, you'll see that the version of Perl you are actually using is 5.00502\, not 5.8.0. Using the correct perl should solve your problems.

p5pRT commented 19 years ago

From @smpeters

[stmpeters - Fri Dec 10 17​:14​:27 2004]​:

On Fri\, Dec 10\, 2004 at 02​:15​:03PM -0600\, Kunkee\, Steve wrote​:

Steve\, I would not have thought anyone would consider 5.8.0 'very' old compared to 5.8.6. But anyway... I checked the version of the perl documentation\, and it clearly identifies itself as 5.8.0. Here is a piece of the doc page on find​: File​::Find(3) perl v5.8.0 File​::Find(3) User Contributed Perl Documentation User Contributed Perl Documentation

                             2003\-06\-19

NAME File​::Find - Traverse a directory tree.

SYNOPSIS use File​::Find; find(\&wanted\, @​directories_to_search); sub wanted { ... }

      use File&#8203;::Find;
      finddepth\(\\&wanted\, @&#8203;directories\_to\_search\);
      sub wanted \{ \.\.\. \}

      use File&#8203;::Find;
      find\(\{ wanted => \\&process\, follow => 1 \}\, '\.'\);

DESCRIPTION These are functions for searching through directory trees doing work on each file found similar to the Unix find command. File​::Find exports two functions\, "find" and "finddepth". They work similarly but have subtle differences.

  find
        find\(\\&wanted\,  @&#8203;directories\);
        find\(\\%options\, @&#8203;directories\);

As you can see\, it is 5.8.0 and it shows a hash for the first argument. We use the same version on Windows\, AND THE OPTION HASH WORKS THERE!!! I say it is a bug. Steve

-----Original Message----- From​: Steve Peters via RT [mailto​:perlbug-followup@​perl.org] Sent​: Friday\, December 10\, 2004 1​:54 PM To​: Kunkee\, Steve Subject​: [perl #32993] Bug in File​::Find when options hash is used with find

[kunkee@​ugs.com - Fri Dec 10 10​:06​:08 2004]​:

This is a bug report for perl from kunkee@​ugs.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.

----------------------------------------------------------------- [Please enter your report here] When I use find (File​::Find) with the options hash\, as illustrated in the code I have included here\, it fails on HP but works on Windows. The message I get is

Not a subroutine reference at

/usr/local/lib/perl5/5.00502/File/Find.pm line 197.

The Perl you are using at /usr/local/bin/perl is a very old Perl. It did not take an options hash reference as an argument. It would only take a subroutine reference for the first argument to find(). Instead\, please try again using the Perl running the perlbug program. This is not a bug in Perl.

If you look closer at the path\, you'll see that the version of Perl you are actually using is 5.00502\, not 5.8.0. Using the correct perl should solve your problems.

Also\, compare the output of /usr/local/bin/perl -v and /ips/udu4/tools/perl/bin/perl -v. Your script used /usr/local/bin/perl\, while perlbug\, and I'm guessing perldoc\, used /ips/udu4/tools/perl/bin/perl. From what I'm seeing in the ticket /usr/local/bin/perl should be Perl 5.00502 and /ips/udu4/tools/perl/bin/perl should be 5.8.0.

p5pRT commented 19 years ago

From kunkee@ugs.com

You are absolutely right. I apologize for being a bit snippy. Steve

-----Original Message----- From​: Steve Peters via RT [mailto​:perlbug-followup@​perl.org] Sent​: Friday\, December 10\, 2004 7​:25 PM To​: Kunkee\, Steve Subject​: [perl #32993] Bug in File​::Find when options hash is used with find

[stmpeters - Fri Dec 10 17​:14​:27 2004]​:

On Fri\, Dec 10\, 2004 at 02​:15​:03PM -0600\, Kunkee\, Steve wrote​:

Steve\, I would not have thought anyone would consider 5.8.0 'very' old compared to 5.8.6. But anyway... I checked the version of the perl documentation\, and it clearly identifies itself as 5.8.0. Here is a piece of the doc page on find​: File​::Find(3) perl v5.8.0 File​::Find(3) User Contributed Perl Documentation User Contributed Perl Documentation

                             2003\-06\-19

NAME File​::Find - Traverse a directory tree.

SYNOPSIS use File​::Find; find(\&wanted\, @​directories_to_search); sub wanted { ... }

      use File&#8203;::Find;
      finddepth\(\\&wanted\, @&#8203;directories\_to\_search\);
      sub wanted \{ \.\.\. \}

      use File&#8203;::Find;
      find\(\{ wanted => \\&process\, follow => 1 \}\, '\.'\);

DESCRIPTION These are functions for searching through directory trees doing work on each file found similar to the Unix find command. File​::Find exports two functions\, "find" and "finddepth". They work similarly but have subtle differences.

  find
        find\(\\&wanted\,  @&#8203;directories\);
        find\(\\%options\, @&#8203;directories\);

As you can see\, it is 5.8.0 and it shows a hash for the first argument. We use the same version on Windows\, AND THE OPTION HASH WORKS THERE!!! I say it is a bug. Steve

-----Original Message----- From​: Steve Peters via RT [mailto​:perlbug-followup@​perl.org] Sent​: Friday\, December 10\, 2004 1​:54 PM To​: Kunkee\, Steve Subject​: [perl #32993] Bug in File​::Find when options hash is used with find

[kunkee@​ugs.com - Fri Dec 10 10​:06​:08 2004]​:

This is a bug report for perl from kunkee@​ugs.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.

----------------------------------------------------------------- [Please enter your report here] When I use find (File​::Find) with the options hash\, as illustrated in the code I have included here\, it fails on HP but works on Windows. The message I get is

Not a subroutine reference at

/usr/local/lib/perl5/5.00502/File/Find.pm line 197.

The Perl you are using at /usr/local/bin/perl is a very old Perl. It did not take an options hash reference as an argument. It would only take a subroutine reference for the first argument to find(). Instead\, please try again using the Perl running the perlbug program. This is not a bug in Perl.

If you look closer at the path\, you'll see that the version of Perl you are actually using is 5.00502\, not 5.8.0. Using the correct perl should solve your problems.

Also\, compare the output of /usr/local/bin/perl -v and /ips/udu4/tools/perl/bin/perl -v. Your script used /usr/local/bin/perl\, while perlbug\, and I'm guessing perldoc\, used /ips/udu4/tools/perl/bin/perl. From what I'm seeing in the ticket /usr/local/bin/perl should be Perl 5.00502 and /ips/udu4/tools/perl/bin/perl should be 5.8.0.