Thanks a lot for helping me. :)
On Jan 25, 2008 6:50 PM, Nagrale, Ajay <[EMAIL PROTECTED]> wrote: > Passing hashes between the scripts would be useful using GDBM > files..Hashes would be stored internally. You can directly load and change > the contents. > > It's easy to handle. But, gdbm files have their own disadvantages when you > keep on adding and deleting the data. > > Try this out. This might help. > > ~Ajay > > -----Original Message----- > From: Chas. Owens [mailto:[EMAIL PROTECTED] > Sent: Friday, January 25, 2008 6:32 PM > To: praveen mall > Cc: beginners@perl.org > Subject: Re: passing array reference from one perl script to another > perl scirpt > > > On Jan 25, 2008 4:45 AM, praveen mall <[EMAIL PROTECTED]> wrote: > snip > > There are two script. From first script I need to call the second > program > > and in second program I want to receive the hash. I have complete hash > in > > first program and calling second program by system call by passing hash > > reference as a parameter. > snip > > I believe you are placing constraints on yourself that do not actually > exist, but we will work with them for now. You need some form of > IPC*. The easiest to understand is the simple file method: script one > writes a file to disk and script two reads that file. Now that we > know how to get the two scripts talking, we need to know how to > transfer a hash along that conduit. We need to serialize it (turn it > into a string that contains all of the information we need). There > are many functions in Perl that can do this for us and which one is > best depends on the data structure to be serialized and your other > needs. For now, let's us one that is in Core Perl: Storable**. > > Here is the first script > #!/usr/bin/perl > > use strict; > use warnings; > use Storable; > > my %h = (a => 1, b => 2, c => 3); > > store(\%h, "/tmp/perlipc.$$") > or die "could not store hash in /tmp/perlipc.$$: $!"; > > system("perl", "second.pl", $$) == 0 > or die "could not run second.pl"; > > Here is the second script > #!/usr/bin/perl > > use strict; > use warnings; > use Storable; > use Data::Dumper; > > my $parentpid = shift; > my $href = retrieve("/tmp/perlipc.$parentpid") > or die "could not retrieve hash from /tmp/perlipc.$parentpid: $!"; > > print Dumper($href); > > > * inter process communication > ** http://perldoc.perl.org/Storable.html > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > > -- Thanks and Regards, Praveen Kumar Mall Jr. SQA Engineer Pune Mo. No. 09850982204