Why not make it a hash?

my $sub = { ref => \&test, params => [$sockethandle] };
$sub->{ref}->(@{$sub->{params}});

sub test {
my $socket = shift;
# ...
}

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: "$Bill Luebkert" <[EMAIL PROTECTED]>
Cc: <perl-win32-users@listserv.ActiveState.com>
Sent: Monday, July 25, 2005 8:19 PM
Subject: Re: references


> hello again,
>
> > > hello all,
> > >
> > > here is a ref/deref problem
> > >
> > > I need to take a socket handle, convert it to a socket ref, then a
scaler
> > > string
> > >
> > > A bit later in the same script, I need to take that scaler string and
turn
> > it
> > > back to a socket ref, and deref it back to the socket handle.
> >
> > Maybe instead of asking for the way to implement your solution, you
should
> > describe the complete problem and see if we can come up with an
alternate
> > solution that is a little less convoluted.  :)
>
> let me clarify my problem.
>
> I have a reference of a subroutine.
>
> eg.
>
> $sub = "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);
>
> $&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?
>
>
>
>
>
>
> _______________________________________________
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to