Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: another 'array to hash' question

by tcf22 (Priest)
on Dec 10, 2003 at 14:32 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://313722]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-20 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found