sub cookup2 {
my %usd = @_;
sub ask_monkey_about {
my $cst = shift;
$usd{$cst};
};
}
####
$ cat t15.pl
use strict;
use warnings;
my @usages = qw( Gilligan 23 Thurston 70 Lovey 98 );
my $ask;
sub cookup2 {
my %usd = @_; # Better be even #.
sub ask_monkey_about {
my $cst = shift;
$usd{$cst};
};
}
sub cookup {
my %usd = @_; # Better be even #.
return sub {
my $cst = shift;
$usd{$cst};
};
}
$ask = cookup ( @usages );
print $ask->("Lovey") . "\n";
cookup2 ( @usages );
print ask_monkey_about("Lovey") . "\n";
####
$/opt/perl5.16/bin/perl t15.pl
Variable "%usd" will not stay shared at t15.pl line 11.
98
98
$