develooper Front page | perl.perl5.porters | Postings from November 1999

[ID 19991115.001] File::Find and local variables

From:
juergen.donnerstag
Date:
November 15, 1999 02:21
Subject:
[ID 19991115.001] File::Find and local variables
Message ID:
C125682A.0038CFD3.00@derumg01.cyberlink.eds.com


To: perlbug@perl.com
Subject: File::Find and local variables
Reply-To: Juergen.donnnerstag@europe.eds.com

This is a bug report for perl from juergen.donnerstag@europe.eds.com generated
with the help of perlbug 1.26 running under perl 5.00557.

-----------------------------------------------------------------
[Please enter your report here]
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

[Please do not change anything below this line]
-----------------------------------------------------------------

---
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





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