Ramprasad,

I have no choice in the data format!

Thanks,

Jerry



-----Original Message-----
From: Ramprasad [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 18, 2003 2:24 AM
To: [EMAIL PROTECTED]; Jerry Preston
Cc: [EMAIL PROTECTED]
Subject: Re: how to read?

Jerry Preston wrote:
> Hi!
> 
> This one is new to me and I need to be able to read $name and $age
from the
> following:
> 
> @history = (
>   {
>     program => 'new',
>     version => '0.42',
>     },
>     input => {
>       '/data' => 0.14,
>       '/home' => undef,
>     },
>     input_contents => '
>       $name   = \'Jerry\'; 
>       $age    = \'25\'; 
>       1;
>     '
>   }   #I think there is a typo
> 

you meant ) right


This is a very strange way of having data. If there is an option please 
change the structure of the data array

Assuming you always have data in the same format
do this

   unshift @history , "dummy";

my %hash = @history;
{
my $name;
my $age;

eval($hash{input_contents}) || warn $@;
           # A stupid way but I can see a better one

print "AGE = $age\n";

}

Ram


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to