perl_mlb
view release on metacpan or search on metacpan
Locale/Maketext.pm view on Meta::CPAN
$q = (defined $2 and length $2) ? $2 : 1;
#print "$1 with q=$q\n";
push @{ $pref{$q} }, lc $1;
}
return # Read off %pref, in descending key order...
map @{$pref{$_}},
sort {$b <=> $a}
keys %pref;
}
###########################################################################
my %tried = ();
# memoization of whether we've used this module, or found it unusable.
sub _try_use { # Basically a wrapper around "require Modulename"
# "Many men have tried..." "They tried and failed?" "They tried and died."
return $tried{$_[0]} if exists $tried{$_[0]}; # memoization
my $module = $_[0]; # ASSUME sane module name!
{ no strict 'refs';
return($tried{$module} = 1)
if defined(%{$module . "::Lexicon"}) or defined(@{$module . "::ISA"});
# weird case: we never use'd it, but there it is!
}
print " About to use $module ...\n" if DEBUG;
{
local $SIG{'__DIE__'};
eval "require $module"; # used to be "use $module", but no point in that.
}
if($@) {
print "Error using $module \: $@\n" if DEBUG > 1;
return $tried{$module} = 0;
} else {
print " OK, $module is used\n" if DEBUG;
return $tried{$module} = 1;
}
}
#--------------------------------------------------------------------------
sub _lex_refs { # report the lexicon references for this handle's class
# returns an arrayREF!
no strict 'refs';
my $class = ref($_[0]) || $_[0];
print "Lex refs lookup on $class\n" if DEBUG > 1;
return $isa_scan{$class} if exists $isa_scan{$class}; # memoization!
my @lex_refs;
my $seen_r = ref($_[1]) ? $_[1] : {};
if( defined( *{$class . '::Lexicon'}{'HASH'} )) {
push @lex_refs, *{$class . '::Lexicon'}{'HASH'};
print "%" . $class . "::Lexicon contains ",
scalar(keys %{$class . '::Lexicon'}), " entries\n" if DEBUG;
}
# Implements depth(height?)-first recursive searching of superclasses.
# In hindsight, I suppose I could have just used Class::ISA!
foreach my $superclass (@{$class . "::ISA"}) {
print " Super-class search into $superclass\n" if DEBUG;
next if $seen_r->{$superclass}++;
push @lex_refs, @{&_lex_refs($superclass, $seen_r)}; # call myself
}
$isa_scan{$class} = \@lex_refs; # save for next time
return \@lex_refs;
}
sub clear_isa_scan { %isa_scan = (); return; } # end on a note of simplicity!
###########################################################################
1;
__END__
HEY YOU! You need some FOOD!
~~ Tangy Moroccan Carrot Salad ~~
* 6 to 8 medium carrots, peeled and then sliced in 1/4-inch rounds
* 1/4 teaspoon chile powder (cayenne, chipotle, ancho, or the like)
* 1 tablespoon ground cumin
* 1 tablespoon honey
* The juice of about a half a big lemon, or of a whole smaller one
* 1/3 cup olive oil
* 1 tablespoon of fresh dill, washed and chopped fine
* Pinch of salt, maybe a pinch of pepper
Cook the carrots in a pot of boiling water until just tender -- roughly
six minutes. (Just don't let them get mushy!) Drain the carrots.
In a largish bowl, combine the lemon juice, the cumin, the chile
powder, and the honey. Mix well.
Add the olive oil and whisk it together well. Add the dill and stir.
Add the warm carrots to the bowl and toss it all to coat the carrots
well. Season with salt and pepper, to taste.
Serve warm or at room temperature.
The measurements here are very approximate, and you should feel free to
improvise and experiment. It's a very forgiving recipe. For example,
you could easily halve or double the amount of cumin, or use chopped mint
leaves instead of dill, or lime juice instead of lemon, et cetera.
[end]
( run in 0.445 second using v1.01-cache-2.11-cpan-71847e10f99 )