Greetings all -

I am having some problems understanding an issue of assignment within a
closure (I think its a closure).  My code is below.  I've added the line
numbers for reference. Note that this is an excerpt from a module.
'$hr_self' is a blessed hash ref to the module. 'FindDGLibDir' is called
with: $hr_self->FindDGLibDir();

1  sub FindDGLibDir
2      {
3      # Modules to use
4      use File::Find;
5      use Cwd;
6
7      my ($hr_self) = @_;
8
9      my $process_file = sub
10          {
11          # Exit the process if we have the directory already
12          return if $hr_self->{dglib_dir} ne '';
13          # This is a directory and the name ends in 'dglib'
14          if (-d && m/dglib$/){$hr_self->{dglib_dir} = $File::Find::name;}
15          };
16
17      # Get the root to cgi-bin
18      cwd =~ m'(.*\/cgi-bin)';
19      # Search cgi-bin looking for dglib and return any errors
20      find(\&$process_file, $1);
21      return 0 if $hr_self->{dglib_dir} eq '';
22
23      return 1;
24      }   # end FindDGLibDir

'$hr_self->{dglib_dir}' at line 14 cannot be assigned to.  If I substitute
'my $string' there, it works fine. '$hr_self->{dglib_dir}' is obviously a
valid var since it is used successfully in line 12. Can anyone tell me why
there is trouble in line 14?

Thanks
Ron



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to