Re: Making hash from two arrays

2004-12-02 Thread Lawrence Statton
John Krahn wrote: > The way I've seen that done sometimes is like this: > > sub frobitz { > my %opt = ( > name => 'blueberry', > color => 'blue', > texture => 'medium', > price = 30, > @_ > ); > > # ... do something useful > } > > T

Re: Making hash from two arrays

2004-12-02 Thread John W. Krahn
Lawrence Statton wrote: I was *JUST* lecturing my student on hash-slices Monday ... Part of that lecture Passing named paramters, implemented as a hash, is a popular style. Look at all of Perl/Tk, for example. For systems where you might pass dozens of parameters to a method (or subroutine),

Re: Making hash from two arrays

2004-12-02 Thread Lawrence Statton
> Dear Sean, > > Hash Slice (only reminded of this the other day). Example code: > > use strict; > use warnings; > > my @first = 'A' .. 'Z'; > my @second = 'a' .. 'z'; > > my %hash; > @[EMAIL PROTECTED] = @second; > > use Data::Dumper; > print Dumper(\%hash); > > __END__ > > Not a particul

Re: Making hash from two arrays

2004-12-01 Thread Jonathan Paton
Dear Sean, Hash Slice (only reminded of this the other day). Example code: use strict; use warnings; my @first = 'A' .. 'Z'; my @second = 'a' .. 'z'; my %hash; @[EMAIL PROTECTED] = @second; use Data::Dumper; print Dumper(\%hash); __END__ Not a particularly "beginner" way to do it though.

Making hash from two arrays

2004-12-01 Thread Sean Davis
I have two arrays of equal length and I would like to make a hash using one array as the keys and one as the values. Is there a simpler way of doing this besides making a loop and counter variable? Thanks, Sean -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL