> The trick is to use {$ref} where you would normally put the variable name:
print "${$rhash}{1}\n"; worked like a charm :)
> So $array[0] becomes ${$ref}[0] (not @$ref[0] which is a "slice").
> And $hash{key} becomes ${ref}{key}.
It seems somewhat inconsistent to me.
While I can dereference s
ftut manpage, it explains all of this
pretty well while avoiding all of the nasty details of refs.
Rob
-Original Message-
From: Tor Hildrum [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 28, 2002 7:46 AM
To: Perl
Subject: Dereferencing a referenced hash.
Is this a bug or a feature?
Is this a bug or a feature?
Or is it just me? :)
!/usr/bin/perl -w
use strict;
use warnings;
my $variable = "variable";
my @array = qw(this is an array);
my %hash = qw(1 this 2 is 3 a 4 hash); ## correct syntax
my $rvariable = \$variable;
my $rhash = \%hash; ## correct syntax
my $rarray = \@ar