in reply to Re: Scalar and void subroutines
in thread Scalar and void subroutines

I had a problem with the previous sub (when calling it in scalar context and not passing a reference). I was able to get the following to work:
sub name { #%% reference argument if it is not a reference my $string = ref $_[0] ? $_[0] : \$_[0]; # processing #%% use return caveat $$string; }

Replies are listed 'Best First'.
Re^3: Scalar and void subroutines
by ikegami (Patriarch) on Nov 10, 2005 at 23:12 UTC

    That's no good either. It clobbers $i in $j = name($i);.

    The fix is to change \do{my ...} to \do{my ... = $_[0]} in my subs. (Just fixed in grandparent.)

      Ahh. I see that you had that. Thanks. :)