Thank you very much.

I come from little bit of C program so was kind of suspcious.. So I am safe
using a reference created in a function.

Thanks again and regards,
Satya



                                                                                       
                                                
                      wiggins@danconia                                                 
                                                
                      .org                     To:      
[EMAIL PROTECTED]                                             
                                               cc:      [EMAIL PROTECTED]             
                                                
                      12/19/2002 11:20         Subject: Re: Passing array to a 
function                                                
                      AM                                                               
                                                
                                                                                       
                                                
                                                                                       
                                                




------------------------------------------------
On Thu, 19 Dec 2002 11:04:27 -0500, [EMAIL PROTECTED]
wrote:

>
> Thank you Sir,
>
> But is it not wrong to create an array in a function and send a reference
> to the array back into the main function?
>
> Because the scope of the array is limited to the function and calling a
> reference that is not available(the variables local in scope to the
> function are collapsed) must be illegal!!
>
> Regards,
> Satya
>

You have just learned what a closure is :-).  At least that is my
understanding of one.  Perl is "smart" enough using reference counting to
know that the variable may still need to be accessed and so doesn't garbage
collect it. Then when the variable that holds the reference is collected so
is what it referred to (assuming there isn't another reference to that).

Neat huh?

http://danconia.org

<snip>








-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to