in reply to REF instead of HASH-ref

my %list = { 'lang' => 'de' };
You want:
my %list = ( 'lang' => 'de' ); my $listref = \%list;
(Note the parens).

Or you can do my $listref = { 'lang' => 'de' };(Note the curly braces).

Once you do that, print $listref->{'lang'} should print de, not any kind of stringified hash.

Check out perlref for more detail. Basically, the parenthese produce a list (which you can assign to a hash and then take a reference), and the curly braces produce an anonymous hash, whose reference you can store in a scalar.

Update
Added a little more detail....

Replies are listed 'Best First'.
Re^2: REF instead of HASH-ref
by zetetes (Pilgrim) on Sep 15, 2004 at 11:47 UTC
    if i do
    my %list = ( 'lang' => 'de' ); my $listref = \%list; print ref($listref);
    i get REF. if i do
    my $listref = { 'lang' => 'de' }; print ref($listref);
    i get HASH.

    i use this with CGI. so i initialize the hash as follow:
    use vars qw($query @parname %list $n ); $query = new CGI; @parname = $query->param; foreach $n (@parname) { $list{$n} = $query->param($n); }
    i then just pass \%list along to a function which takes the refenrence and uses the hash again. i used exactly this code (copy/paste) in another app, there it worked fine. the environment is the same, too.

    kind of puzzled. update: if i update the initialization to:
    $query = new CGI; @parname = $query->param; foreach $n (@parname) { $hashref->{$n} = $query->param($n); }
    everything works fine. hm...
        thank you, VSarkiss for your patience and the hint. i'll have a look at the doc.