In your "update", you are actually resetting the entire value of $the_data[1] to point to a new hash reference, which has only y defined.
 
Try this instead:
 
$the_data[1] = { x => 'A', y => 'B' };
print $the_data[1]->{x}, "\n";
$the_data[1]->{y} = 'C';
print $the_data[1]->{y}, "\n"; 
 
HTH,
Ricky
-----Original Message-----
From: Andrew Wax [mailto:[EMAIL PROTECTED]]
Sent: Monday 21 January 2002 4:05 PM
To: [EMAIL PROTECTED]
Subject: Another Question - hashes please ..

Good Afternoon - I have a hash that I define as:
 
$the_data[1] =
{
    x => "A",
    y => "B",
};
print $the_data[1] -> {x};
 
works and prints A
 
 
if I want to update the value of 'y' to C like:
$the_data[1] =
{
    y => "C"
};

print $the_data[1] -> {x};
 
this does not work because it prints out a blank.  Obviously I am not updating my value of part of the hash.  Is there an easy way to just update the value of $the_data -> {y} to be C without having to remember $the_data -> {x}
 
Thank you for your help -everyone has been very helpful with these basic but annoying 'bumps'
 
Andrew
 

Reply via email to