SPUG: Passing arguments to a code reference

Colin Meyer cmeyer at helvella.org
Tue Apr 18 14:44:22 PDT 2006

On Tue, Apr 18, 2006 at 02:22:23PM -0700, mike wrote:
> Hi there
> I've tried a few things, including using the PROTO in the sub declaration,
> but I cant seem to figure out how to pass some args to a code ref after the
> creation of the code ref
> This code ref is being passed to an object which would like to add a hashref
> to the argument list.
> This is in the perlsub documentation
>     $subref = sub (PROTO) : ATTRS BLOCK; # with proto and attributes

Do you mean like this?

  my $printer = sub { my $arg = shift; print "$arg\n" };
  $printer->( 'it works' );


More information about the spug-list mailing list