in reply to Passing hash references

Since $names is already a hashref, there is no need to reference the reference again. Please change
my $valid_names = &validateNames(\$names);
to
my $valid_names = &validateNames($names);
in your sub validateNames you can access the hashref with the -> operator.
sub validateNames{ my $valid_names=shift; print $valid_names->{SCM555}->{email}; print $valid_names->{SCM556}->{name}; }
Boris

Replies are listed 'Best First'.
Re^2: Passing hash references
by Tanktalus (Canon) on Jan 31, 2005 at 16:23 UTC

    Boris,

    Just to be consistant with the original poster's code style, whether that's the way you do it or not (it happens to be the way I do things, but it seems I'm in the minority ;->), the arrow operator after a close-brace is not required:

    print $valid_names->{SCM555}{email};
    Rhodium - note, too, that the quotes inside the braces are optional. I prefer without the quotes (unless required - which they are for certain things), but I do recommend consistancy, even if you disagree with other aspects of my coding style ;-)
    print $valid_names->{'SCM555'}{'email'};