Re: pass by reference from parent to child
by $Bill Luebkert other posts by this author
Aug 2 2004 5:52AM messages near this date
view in the new Beta List Site
Jack Roth/Inv/MetLife/US is out of the office.
|
RE: pass by reference from parent to child
bruce wrote:
> hi...
>
> is it possible to pass an arg by ref from parent to child via exec/system
> shell and be able to retrieve the original value...
I thought this was pretty much answered. You cannot pass objects to
children/processes - what you can pass is basically ASCII strings.
In UNIX, you could open a connection and fork a child and be able to
access the FDs the parent opened, but we're talking Win32 here and
you would have to go to threads and most Perl modules aren't thread
safe yet.
You can pass data though files and shared memory etc, but not active
objects like open file or DB handles.
> #use strict;
> use DBI;
> require ('mysql.inc');
>
>
> my $dbh = "";
>
> print "open db\n";
> $dbh = open_dbi();
>
> # at this point, dbh should be the connection id...
> print "dbh = ".$dbh."\n";
> my $db1;
> my $db2;
> $db1 = \$dbh;
> print "db1 = ".$db1."\n";
> system 'perl', 'aaa.pl', $db1;
>
> $db2 = $$db1;
> print "db2 = ".$db2."\n";
>
> this successfully gets 'db2' to have 'dbh', which is what one expects...
>
> and within the child app, it actually gets the correct REF... however, i'm
> not sure if it's possible to retrieve the actual val via this approach..
>
> using the $$arg doesn't get the correct val in the child app...
Passing a handle to another process will do you no good - it isn't
usable by the other process. The other process would have to open
it's own object to access the data source.
--
,-/- __ _ _ $Bill Luebkert Mailto:dbecoll@[...].net
(_/ / ) // // DBE Collectibles Mailto:dbe@[...].com
/ ) /--< 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@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
$Bill Luebkert
bruce
bruce
Angelos Karageorgiou
|