in reply to Trouble passing hash into function
Are you passing the hash:
use strict; use warnings; use Data::Dump::Streamer; my %hash = (a => 1, b => 2, c => 3); printHash (%hash); sub printHash { my %subHash = @_; print "$_ => $subHash{$_}\n" for keys %subHash; }
Prints:
c => 3 a => 1 b => 2
or a reference to the hash:
... printHash (\%hash); sub printHash { my ($subHash) = @_; print "$_ => $subHash->{$_}\n" for keys %$subHash; }
which prints as above. Or are you doing something else? If the snippets above don't clear the problem up, generate a similar sample demonstrating the problem and show it to us.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trouble passing hash into function
by dbonneville (Acolyte) on Sep 05, 2007 at 23:10 UTC | |
by GrandFather (Saint) on Sep 05, 2007 at 23:24 UTC | |
by Fletch (Bishop) on Sep 05, 2007 at 23:30 UTC | |
by dbonneville (Acolyte) on Sep 06, 2007 at 00:39 UTC |