in reply to Re: Re: Re: Working with references to scalars
in thread Working with references to scalars

For me they work differently.

put_string_ref( \(get_string()) ); # pass return value of get_string() put_string_ref( \(&get_string) ); # pass a coderef pointing to &get_s +tring

I guess if we take what tye mentioned in another response, in that we don't need the brackets for this to work, then it looks like the following holds true:

\&func # gives you a reference to a function \func() # gives you a reference to the return value of func

and a quick test verifies this:

sub func { "the string"; } print \&func, "\n"; # prints CODE(0x814d990) print \func(), "\n"; # prints SCALAR(0x813aa8c)

I guess what I've learned here is that there can be a big difference between &func and func(). I used to use them interchangably, but I will be more careful from now on.

Thanks for your help...