And you can write your own function that takes an implicit $_ using the (_) prototype.
My favourite use for $_ is when defining a function that accepts a coderef. Example
# This is a fairly useless function which is basically
# just a copy of grep which enforces numeric context
# on the list items...
#
sub filter_nums (&@)
{
my $coderef = shift;
return
grep { $coderef->() }
map { 0 + $_ }
@_
}
my @even = filter_nums { not($_ % 2) } qw(1 2 3 4 potato);
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|