• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

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
0
rahul_milo
Asked:
rahul_milo
1 Solution
 
ozoCommented:
do "defs.h";
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now