Howa howa howa ha.
Come on, man! RTFN! Or think about it! What is your subroutine
returning? A list of keys and values: no delimiters. So how
does the receiver know when the second hash starts?
The way to do it is to (always!) return references to hashes:
\%that, \%what. The caller then dereferences:
#! perl -w
my ($h, $i) = makeh();
foreach (keys %$h){
print "$_ - ",
%$h->{$_}, # Deref: %$h could be written %{$h} for clarity
"\n";
}
sub makeh {
my (%that, %who);
$that{eins} = "one";
$that{zwei} = "two";
$that{drei} = "three";
$who{kris} = "wolff";
$who{alex} = "seidel";
return(\%that, \%who);
}
__END__
hth
lee
Kristofer Wolff wrote:
>
> Hi all, I found out somthing that is really bad !
>
> i have a sub routine thats return a hash:
>
> ---------------------------------
> my %h = makeh();
> sub makeh
> {
> my %that;
> $that{eins} = "one";
> $that{zwei} = "two";
> $that{drei} = "three";
> return(%that);
> }
> --------------------------------
>
> fine ! it works for me since more than a year in a application. Today I
> change the script and add somthing that rewuires 2 hashes and i tryed this
>
> --------------------------------
> my (%h, %i) = makeh();
> sub makeh
> {
> my %that, %who;
> $that{eins} = "one";
> $that{zwei} = "two";
> $that{drei} = "three";
> $who{kris} = "wolff";
> $who{alex} = "seidel";
> return(%that, %who);
> }
> --------------------------------
>
> but now, i have EVERYTHING in %h and nothing in %i !!!!
> foreach(keys %h)
> {
> print "$_ - $h{$_}\n";
> }
>
> will show:
> eins - one
> kris - wolff
> zwei - two
> drei - three
> alex - seidel
>
> IS THIS A BUG OR AM I WRONG ???????
--
Lee Goddard <[EMAIL PROTECTED]>
-------------------------------------
Perl : XML : XSLT : XHTML / JS : Java
"Post-modernism....the meta-narrative that denies meta-narrative."
- Cedric Watts, Sussex 1997
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web