in reply to Re: Aliasing and return, how does return work?
in thread Aliasing and return, how does return work?

I think this could work but I'm not having much joy so far. I'm still on perl version 5.6.1 which could easily be a factor.

Will an lvalue sub work when called as &ret = 123?

I ask because I'm trying to do parameter preprocessing for the caller and was doing it with &ret.

  • Comment on Re^2: Aliasing and return, how does return work?

Replies are listed 'Best First'.
Re^3: Aliasing and return, how does return work?
by japhy (Canon) on Jun 30, 2004 at 05:01 UTC
    I'm not sure if lvaluable subs work in 5.6.1. This code works for me with Perl 5.8.4:
    sub ret :lvalue { $_[0] } sub foo { &ret++; print "ARGS: <@_>\n"; } my ($x, $y) = (10, 20); foo($x, $y); __END__ ARGS: <11 20>
    Make sure you aren't accidentally shifting the argument you're planning on setting before you set it.
    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
      Got your results with 5.6.1, must be my sketchy understanding at fault.

      Aha, it was my testing code messing up, reassigning during the middle of the test. Thanks

      update: I may have spoken too soon...