This may work :

&monkey("key","value","key1","value1");

sub monkey {
        %new_hash = ();
        %new_hash = $_[0];
        return %new_hash;
}

Dan

> -----Original Message-----
> From: Ben Siders [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, January 14, 2003 10:57 AM
> To: [EMAIL PROTECTED]
> Subject: Question about creating a hash of key-value pairs 
> based on sub parameters.
> 
> 
> I have a subroutine that will receive parameters as follows:
> 
> key1, value1, key2, value2, key3, value3, ... keyN, valueN
> 
> I want to create a hash of key1 => value1, key2 => value2, 
> ... , keyN => 
> valueN in the subroutine.  I'm curious if there's a Perl "trick" to 
> doing this beyond the obvious looping solution.
> 
> For example:
> 
> while ( some condition )
> {
>       my $key  = shift;
>       my $value = shift;
> 
>       $myHash{$key} = $value;
> }
> 
> What's my exit condition?
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to