P
penguinista
# load a map into memory
sub readmap
{ my ($map, $file) = @_; # $map is a hashref here
my ($line, $type, $name);
return if eof $file;
$line = <$file>;
chomp $line;
if ($line =~ /\{\s*(\w+)\s+(\w+)/)
{ $type = $1; $name = $2;
if (!defined($map->{$name}))
{ $map->{$name} = {'parent'=>$map, 'name'=>$name, 'type'=>$type}; }
&readmap($map->{$name}, $file);
}
elsif ( $line =~ /(\w+)=(.+)/ )
{ $map->{$1} = $2; # this sets field value, then shoots off to garbage
}
elsif ($line =~ /\}/)
{ return; }
else {}; # error
}
It the above subroutine, the line $map->{$1} = $2 assigns key+value into
the hash as expected, then shoots off to a sub DESTROY {} in package
IO::Handle; before returning to my code after the call to the subroutine
that first calls recursive routine readmap. $1 = 'val', $2 = '"Login"'
running perl 5.8.5 in cygwin.
any ideas?
sub readmap
{ my ($map, $file) = @_; # $map is a hashref here
my ($line, $type, $name);
return if eof $file;
$line = <$file>;
chomp $line;
if ($line =~ /\{\s*(\w+)\s+(\w+)/)
{ $type = $1; $name = $2;
if (!defined($map->{$name}))
{ $map->{$name} = {'parent'=>$map, 'name'=>$name, 'type'=>$type}; }
&readmap($map->{$name}, $file);
}
elsif ( $line =~ /(\w+)=(.+)/ )
{ $map->{$1} = $2; # this sets field value, then shoots off to garbage
}
elsif ($line =~ /\}/)
{ return; }
else {}; # error
}
It the above subroutine, the line $map->{$1} = $2 assigns key+value into
the hash as expected, then shoots off to a sub DESTROY {} in package
IO::Handle; before returning to my code after the call to the subroutine
that first calls recursive routine readmap. $1 = 'val', $2 = '"Login"'
running perl 5.8.5 in cygwin.
any ideas?