Where you do this:
 my @[EMAIL PROTECTED] = @valuesarray;

do this:
my %hash = ();
@[EMAIL PROTECTED] = @valuesarray;

and it should work.  In this case, perl needs to know its a Hash before
you can use the {} to specificy the slice.


On Fri, Mar 19, 2004 at 05:16:17PM -0600, Shiping Wang wrote:
> At 04:48 PM 3/19/2004 -0500, you wrote:
> >stuart meacham wrote:
> >> If I have 2 arrays that I want to assign to the keys and values of a
> >> hash respectively, what would be easiest way to do that?
> >
> >   @[EMAIL PROTECTED] = @valuesarray
> >
> >--
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> ><http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> I tried:
> --------------------------------------------------------------------------------------------------
> use strict;
> use warnings;
> use Data::Dumper;
> 
> my @keysarray = qw/a c b d f g t l w x v z/;
> my @valuesarray = qw/1 2 3 4 5 6 7 8 9 10 11 12/;
> 
> my @[EMAIL PROTECTED] = @valuesarray;
> 
>    print Dumper @[EMAIL PROTECTED];
> -------------------------------------------------------------------------------------------------
> And get syntax error at "@hash{"    ???
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 

-- 
Brad Lhotsky <[EMAIL PROTECTED]>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to