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

File::Find and local variables #851

Closed
p5pRT opened this issue Nov 15, 1999 · 1 comment
Closed

File::Find and local variables #851

p5pRT opened this issue Nov 15, 1999 · 1 comment

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Nov 15, 1999

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

Searchable as RT1779$

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 15, 1999

From juergen.donnerstag@europe.eds.com

I always try to avoid global variables. Unfortunately with File​::Find that is
not possible.
However there is a solution. Simply forward the hash variable $wanted to
File​::Find​::wanted(). Thus us may define variables 'local' to the inner
procedure.

E.g.​: forward a file pattern to the function without use of a
  global variable.

%hPara = ( wanted => \&sub_wanted, pattern => $pattern );
find( \%hPara, $direc );

The changes I made to lib/File/Find.pm are
103c103
< $wanted->{wanted}->();
---

      $wanted\->\{wanted\}\->\( $wanted \);

113c113
< $wanted->{wanted}->();
---

      $wanted\->\{wanted\}\->\( $wanted \);

127c127
< $wanted->{wanted}->();
---

    $wanted\->\{wanted\}\->\( $wanted \);

155c155
< $wanted->{wanted}->();
---

   $wanted\->\{wanted\}\->\( $wanted \);

166c166
< $wanted->{wanted}->() unless $bydepth;
---

   $wanted\->\{wanted\}\->\( $wanted \) unless $bydepth;

191c192
< $wanted->{wanted}->() if $bydepth;
---

   $wanted\->\{wanted\}\->\( $wanted \) if $bydepth;

Juergen

Perl Info


Site configuration information for perl 5.00557:

Configured by root at Thu Jun 10 07:47:57 MET DST 1999.

Summary of my perl5 (revision 5.0 version 5 subversion 57) configuration:
  Platform:
    osname=solaris, osvers=2.5.1, archname=sun4-solaris
    uname='sunos es130065 5.5.1 generic_103640-23 sun4u sparc sunw,ultra-2 '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    use64bits=undef usemultiplicity=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.8.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:



@INC for perl 5.00557:
    /net/appl/bo_utils/perllib
    /usr/local/lib/perl5/5.00557/sun4-solaris
    /usr/local/lib/perl5/5.00557
    /usr/local/lib/perl5/site_perl/5.00557/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.00557
    .


Environment for perl 5.00557:
    HOME=/
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/lib:/usr/openwin/lib:/usr/dt/lib:/opt/SUNWsymon/lib
    LOGDIR (unset)

PATH=/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/sbin:/usr/openwin/bin:/net/appl/scripts:/usr/local/bin:/usr/ucb:/usr/openwin/bin:/usr/proc/bin:.:/usr/local/bin:/usr/ccs/bin:.:/opt/SUNWsymon/bin
    PERL5LIB=:/net/appl/bo_utils/perllib
    PERL_BADLANG (unset)
    SHELL=/usr/bin/ksh

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.