Well, you can stop trying to use a string as a hash reference?

For starters, you should never name variables $a or $b because these are
special variables if you ever do a sort.

Besides that, though, you are assigning $a the value '20020603'.  Then you
assign the value of $a to the hash key $a, making that key a string as well.
Then you are trying to access the hash created by dereferencing $h{$a}, only
$h{$a} is a string with the value '20020603', not a hash reference.  

So I guess I don't see what it is you're trying to accomplish.

-----Original Message-----
From: chris [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 21, 2002 4:18 PM
To: [EMAIL PROTECTED]
Subject: Can't use string as hash ref?


How do I do the following without getting the message
Can't use string as hash ref while strict refs in use

use warnings;
#use strict;
my($a, @b, $c);
$a = '20020603';
$b[1] = 'name1';
$b[2] = 'name2';
$b[3] = 'name3';
my %h;
$h{$a} = $a;
$h{$a}->{$b[1]}= 1;
$h{$a}->{$b[2]}= 2;
$h{$a}->{$b[3]}= 3;
print $h{$a}->{$b[1]} . "\n";
print $h{$a}->{$b[2]} . "\n";
print $h{$a}->{$b[3]} . "\n";

-- 
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