trying to understand closure and callback(bit over my head but)
while I think i grasp most of the ideas from below program.. I don't think I understand why ( ) is needed in
my $sum = $subs{$_}{GETTER}->( ); #!/usr/bin/perl use warnings; use strict; use File::Find; sub create_find_callbacks_that_sum_the_size { my $total_size = 0; return(sub { $total_size += -s if -f }, sub { return $total_size } ); } ## set up the subroutines my %subs; for my $dir ( qw(bin lib man) ) { my ( $callback, $getter ) = create_find_callbacks_that_sum_the_size( ); $subs{$dir}{CALLBACK} = $callback; $subs{$dir}{GETTER} = $getter; } ## gather the data for ( keys %subs ) { find($subs{$_}{CALLBACK}, $_); } ## show the data for ( sort keys %subs ) { my $sum = $subs{$_}{GETTER}->( ); print "$_ has $sum bytes\n"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/