How would I write a function that accepts something like the map function does?
Example:
$func = sub { print $_[0], "hi\n" };
&something($f);
sub something
{
my $func = shift;
for ($i = 0; $i < 5; $i++)
{ $func->($i); }
}
works fine.
but then if I did
&something( { print $_[0], "hi\n" } );
it wont work and says func is an undefined reference.
So my question would be how would I write a function that accepts parameters like perls map function?
map { s/a/b/g } @somelist;