Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-10-05 15:43 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (24 votes). Check out past polls.