On Mon, Feb 05, 2001 at 11:39:47AM +0100, Bart Lateur wrote:
> What do you mean, "nope"? It *is* in use. The (?{...})
> embed-perl-code-in-a-regex feature sets it. With a return value. Hah.
Oh.  I wasn't at home, so I had to use the copy of perlvar on perldoc.org,
which apparently isn't up-to-date with that.  Or I just missed it.  Whoops.

Perhaps $} would work.  Mnemonic: it's what get returned when you hit the
"}" at the end of your sub.

The idea is you should use this when you want a half-return -- set the
return value, but don't return from the sub yet because you still have more
to do.

In most languages, you do this with
{
 $ret = 42;
 close FILE;
 unlock $stuff;
 #yadda
 return $ret;
}

By the time you get to the last line, you've already forgoten WTF you named
the return variable.

> BTW I think the whole idea is bad. I like "return FOO". Neat and simple.
Well, I thought so too at the beginning of this thread.  But, however, I've
come to realize that sometimes you want to set the returned value, do some
other stuff, and then leave the sub.  In this case, it's cleaner to do 

> At least it's independent of the sub's name. I wish this could be
> extended to doing recursive calls without having to say the subs own
> name, again.
I agree, making the magic variable be the name of the sub is a bad idea.

Your idea for a name for the currently executing sub is interesting, I
think.  I'm going to fork the thread.

        -=- James Mastros
-- 
"My country 'tis of thee, of y'all i'm rappin'!  Lan where my brothers
fought, land where our King was shot -- from every building top, let freedom
happen!"
        -=- Monique, Sinfest[.net]
AIM: theorbtwo       homepage: http://www.rtweb.net/theorb/

Reply via email to