in reply to (tye)Re: Global, Local, what the..?
in thread Global, Local, what the..?

tye: I think you're confusion stems from our bad examples :)

You are right in your assessment, but the code below should clarify this. Because we're localizing arguments to the sub, you can see how it returns the last evaluated statement. The code below will print "his hat" (without the quotes):

use strict; my @list = qw( this that foo bar ); print join ' ', mungeIt( @list ); sub mungeIt { my @localList = @_; my @stuff = map { s/th/h/ ? $_ : () } @localList; }

Cheers,
Ovid

Update: Oh! I misunderstood tye's question, but clarified the answer. Oh well. All's well that ends well.

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
(tye)Re: (Ovid - subroutine return example w/map)
by tye (Sage) on Dec 15, 2000 at 03:34 UTC

    FYI, I understood that return is optional and that a subroutine will return the value of the last statement executed. I just didn't see what that had to do with the original question. I mean, antjock asked several questions about the lack of the return and return values, but I thought the real question was "why does this work?" and I didn't think anyone had answered that... and I wasn't sure I was just missing something (I can be slow some days). (:

            - tye (but my friends call me "Tye")