#!/usr/bin/perl -w use strict; sub print_me { my $arg = shift || "Hello World!\n"; print $arg; } my %hash = (no_arg => sub { &print_me()}, with_arg => sub {&print_me("Hello again!\n")} ); $hash{no_arg}->(); $hash{with_arg}->();
In reply to Re: Declaring a code ref with arguments
by cianoz
in thread Declaring a code ref with arguments
by !unlike
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |