Link to home
Start Free TrialLog in
Avatar of rahul_milo
rahul_milo

asked on

problem in assigning hash variable.

Hi,
I have one defs.h file which is made at run time.
Another file use this defs.h file and I want to assign a hash variable from defs.h
file to a local hash variable.
I cannot require this defs.h file as it is made at run time.
I am unable to assign that variable.

code is goes like this:
#File defs.h

our %global_hash = ('car'=> 'lanser','bike'=> 'ducati');

#File test.pl
#!/usr/bin/perl -w
my $file = "defs.h";
open(FD,"<$file");
while(<FD>)
{
  if($_ =~ /\%global_hash/)
 {
     chop($_); # chop newline
     chop($_);
     chop($_); # chop ;
     my $pos = index($_,"=");
     my %local_hash =
     substr($_,$pos+1,length($_));
     my @ky = keys %scp_hash;
     my @vl = values %scp_hash;
     print "keys=@ky";
     print "car=".$scp_hash{'car'};
  }# if
} #while
close(FD);
I m not getting the values in %local_hash.
can u help me in this case.I can't require defs.h file.
thanks
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial