eserte / perl-tk

the perl module Tk
https://metacpan.org/release/Tk
Other
44 stars 31 forks source link

errata Tk->findINC usage in demo instead of Tk->findINC #30

Open bzimage-it opened 6 years ago

bzimage-it commented 6 years ago

my /usr/lib/x86_64-linux-gnu/perl5/5.22/Tk.pm shows to me:


sub findINC
{
 my $file = join('/',@_);
 my $dir;
 $file  =~ s,::,/,g;
 foreach $dir (@INC)
  {
   my $path;
   return $path if (-e ($path = "$dir/$file"));
  }
 return undef;
}

Since it has not the my $self = shift; instruction at the beginning it seems to be used with :: operator, not with -> ;

however the 'demo' directory examples widely use the -> in fact:


$ cd /usr/lib/x86_64-linux-gnu/perl5/5.22/Tk/demos
$ grep -ri '>findINC' . | wc
     37     195    3196
$ grep -ri ':findINC' . | wc
      0       0       0
$ 

I suppose the bug is in demo files due findINC shall be static as defined.

chrstphrchvz commented 5 years ago

@bzimage-it I think you meant to put "instead of Tk::findINC" in the title of this issue.

Indeed the only example of Tk::findINC I found in the Perl/Tk distribution is in t/zzPhoto.t.

I'm not familiar with using findINC, but according to Mastering Perl/Tk §13.24 "Really Miscellaneous Methods", there is (or was) a distinction between using Tk::findINC and Tk->findINC:

Tk->findINC searches for files in all Tk subdirectories of the current @INC path. […] If using the form Tk::findINC, then only @INC is searched, not the subdirectories.