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
rahul_miloAsked:
Who is Participating?
 
ozoCommented:
do "defs.h";
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.