Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: another 'array to hash' question

by tcf22 (Priest)
on Dec 10, 2003 at 14:32 UTC ( #313722=note: print w/replies, xml ) Need Help??


in reply to another 'array to hash' question

Normally doing this is not good practice. If you need the variable names, then you should most likely use a hash.

Here is an example of using an array to build a hash, which may help you, based on the title of your post.
#!/usr/bin/perl -w use strict; use Data::Dumper; my @keys = qw( fn ln age ); my @values = qw( Joe McCarty 89 ); my %hash; @hash{@keys} = @values; print Dumper \%hash;

- Tom

Replies are listed 'Best First'.
Re: Re: another 'array to hash' question
by punkish (Priest) on Dec 10, 2003 at 15:07 UTC
    y'know... this might work in my above code example. Thanks for this.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://313722]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2020-05-27 07:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (153 votes). Check out past polls.

    Notices?