Jeremy A wrote:

> hi all,
> 
> I have learned how to pass a sub as a parameter into another subroutine, 
> then execute it.
> 
> My problem is, how do execute the referenced sub, and  inheret the 
> variables of the calling sub?
> 
> Thanks in advance for any help.
> 
> Regards,
> 
> Jeremy A.
> 
> ------Code-----------
> 
> sub writeline
>   {
>   my ($action) = @_;
>   my $test = "hi"; <---variable private too sub.
> 
>   &$action; <-- want too inherit "$test" into sub without passing it in as 
> a parameter.

    &$action ($test);   # there is no way I kow of why not pass as arg ?

>   }
> 
> 
>   sub hello
>   {
>       print $test." hello\r\n";

        print $_[0] . " hello\n";

>   }
> 
> 
> writeline(\&hello);


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to