[EMAIL PROTECTED] wrote:

> hello again,
> 
> let me clarify my problem.
> 
> I have a reference of a subroutine.
> 
> eg.
> 
> $sub = "test";

Better expressed like this:

my $subref = \&test;

> ..deref and execute
> 
> &$sub;
> 
> ...
> 
> sub test {
> my ($sockethandle,$blah...) = @_;
> ..do something
> }
> ........
> 
> in order to pass the paramenters, i decided to do this : 
> 
> sub main {
> 
> my $sub = "test|$sockethandle";
> ($sub,@_) = split(/\|/,$sub);
> 
> $⊂
> }
> 
> 
> if this is to work correctly, I need to take a socket handle, convert it to a 
> socket ref, then a scaler, so i can pass it as a parameter. in order to use 
> the 
> socket later, i have to take the scaler, convert it to the socket ref, then 
> dereference it.
> 
> Is there an easier way to pass parameters with a subroutine reference? 

Just pass a ref rather than concatenating scalar strings together.

use strict;
use warnings;

my $subref = \&test;    # reference to sub

&$subref (\*STDOUT, "test args\n");     # pass FH ref and string

sub test {
        my ($FH, $blah) = @_;

print $FH $blah;

}

__END__

-- 
  ,-/-  __      _  _         $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
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to