How to pass CODE reference in hash?

2003-07-26 Thread LI NGOK LAM
I hope to design an interface of a function like this (not in OO way) : sub tell_error { print Error for @_ } sub Check_err { my %argv = @_; } Check_err ( TYPE = [1, 1, \tell_error('Type')], DATA = [ 1, 2, \tell_error ('Data')] ); In Check_err, I want tell_error ('Type')

Re: How to pass CODE reference in hash?

2003-07-26 Thread Jeff 'japhy' Pinyan
sub tell_error { print Error for @_ } Check_err ( TYPE = [1, 1, \tell_error('Type')], DATA = [ 1, 2, \tell_error ('Data')] ); You can't take a reference to a function WITH ARGUMENTS. You must either do foo = \function or foo = sub { function(args) } Since you want to pass arguments,