Thanks! I got it to work using:
$server {$thread}->{$logfile}->{$delay} = [EMAIL PROTECTED]; But I guess it's better to use an array reference? -----Original Message----- From: Jenda Krynicky [mailto:[EMAIL PROTECTED] Posted At: Friday, November 21, 2003 3:37 AM Posted To: Perl Conversation: Array de-referencing problem Subject: Re: Array de-referencing problem From: "Paul Harwood" <[EMAIL PROTECTED]> > I wrote the following code: > > $thread = "TEFD0"; > $logfile = "V_DEBUG12121.txt"; > $delay = "10232"; > @servers = qw (SERVER1 SERVER2 SERVER3 SERVER4); > $server {$thread}->{$logfile}->{$delay} = @servers; The first problem is here. You are evaluating the array in scalar context and storing the resut (the length of the array) into the hash. The line above is equivalent to $length = @servers; $server {$thread}->{$logfile}->{$delay} = $length; The values of a hash can only be scalars! This means that you have to store a reference to the array in the hash: $server{$thread}->{$logfile}->{$delay} = [EMAIL PROTECTED]; > print @$server {$thread}->{$logfile}->{$delay}; > > My expectation is that it would simply print out the list value of > @servers. Instead I get an error: Can't use an undefined value as a > HASH reference. The problem in this case is that perl thinks that you want to use the $server as a reference to a hash (or a name of a hash variable in your case), then take a hash slice, and then use that hash slice as a reference to hash. That is it treats the line like this: print @{$server}{$thread}->{$logfile}->{$delay}; while what you want is print @{$server{$thread}->{$logfile}->{$delay}}; P.S.: You've accidentaly used "symbolic references". They are a bad idea usualy even if you do want to use them, but in this case they just confused the matter. You DO want to use strict; use warnings; no warnings 'uninitialized'; on top of all your scripts. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- 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]