Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - hash of arrays question

 
Thread Tools Search this Thread
Old 06-11-2006, 12:56 PM   #1
Default hash of arrays question


I'm new to perl and have a question. The perl book
says that hashes map keys to values. Using the reverse
function you can map values to keys. My problem is
I have a hash of arrays and I want to map an array
of values to a particular key. Is there any way to
do this?

Thanks,

John


John Gregory
  Reply With Quote
Old 06-12-2006, 01:48 AM   #2
Skeleton Man
 
Posts: n/a
Default Re: hash of arrays question

>I'm new to perl and have a question. The perl book
>says that hashes map keys to values. Using the reverse
>function you can map values to keys. My problem is
>I have a hash of arrays and I want to map an array
>of values to a particular key. Is there any way to
>do this?


There are two ways to do this:

$sample{'key1'} = ['item1', 'item2', 'item3']; # Array of values mapped to a
single hash key (note the use of square brackets [])
print $sample{'key1'}[0]; # Prints "item1"

Or:

@data = ('item4, 'item5', 'item6', 'item7'); # Create a new array
$sample{'key2'} = \@data; # Take a reference to the
array (backslash operator), you could use any existing array here too.
print $sample{'key2'};


Let me know if you need anything explained a little more clearly

Regards,
Chris




  Reply With Quote
Old 06-12-2006, 12:38 PM   #3
mzi
 
Posts: n/a
Default Re: hash of arrays question

Skeleton Man wrote:

>>I'm new to perl and have a question. The perl book
>>says that hashes map keys to values. Using the reverse
>>function you can map values to keys. My problem is
>>I have a hash of arrays and I want to map an array
>>of values to a particular key. Is there any way to
>>do this?

>
> There are two ways to do this:
>
> $sample{'key1'} = ['item1', 'item2', 'item3']; # Array of values mapped to
> a single hash key (note the use of square brackets [])
> print $sample{'key1'}[0]; # Prints "item1"
>
> Or:
>
> @data = ('item4, 'item5', 'item6', 'item7'); # Create a new array
> $sample{'key2'} = \@data; # Take a reference to the
> array (backslash operator), you could use any existing array here too.
> print $sample{'key2'};
>
>
> Let me know if you need anything explained a little more clearly


This means: hash values can be references.

--
mzi
  Reply With Quote
Old 09-27-2006, 11:43 AM   #4
Michael Gaylord
 
Posts: n/a
Default Re: hash of arrays question

> I'm new to perl and have a question. The perl book
> says that hashes map keys to values. Using the reverse
> function you can map values to keys.


AFAIK, the reverse function takes a list/array, and returns
it in the opposite order.



> My problem is
> I have a hash of arrays and I want to map an array
> of values to a particular key. Is there any way to
> do this?


Something like this?

@contents = (1,2,3,4,5)
$hashofarrays{key} = \@contents

I can then reference like follows:

print $hashofarrays{key}[2]

outputs: 3


  Reply With Quote
Old 08-07-2008, 04:47 AM   #5
joesmith
Junior Member
 
Join Date: Aug 2008
Posts: 1
Default Joe

Hi

I tried this output but didn't print

$sample{key1} =(1,2,3,4,5);
print $sample{key1}[0]; - it doesn't print the output of 1.


any idea why ?
joesmith is offline   Reply With Quote
Old 09-15-2008, 06:43 AM   #6
mringrate
Junior Member
 
Join Date: Sep 2008
Posts: 3
Default Add Me To Your List

MAKE $250,000 IN WEEKS using PAYPAL

AS SEEN ON OPRAH AND 20/20
**Proven by various, highly-respected U.S. TV and Radio programs as
being 100% legal, feasible and true. **
**Oprah Winfrey and ABC's investigation team 20/20 also prove it can
be done.***

THIS REALLY CAN MAKE YOU EASY MONEY!! IT WORKS!!! BUT YOU HAVE TO
FOLLOW The LETTER FOR IT TO WORK!!!! THIS IS NOT A PYRAMID SCAM!! :
I came across an article similar to this that said you could make
thousands of dollars within weeks with only an initial investment of
$6.00!

...here's how!

PayPal verifies that this $6 investment program is 100% legal and is a
big hit this year see their note below or ask them directly...

For a simple investment of 15-30 minutes and just $6, it is 100% worth
it to make thousands so quickly. This is not another scam that takes
lots of your hard earned money; this is a no risk investment that will
make you thousands of dollars very easily and quickly.

Turn $6 into $15,000 in only 30 days...here's how! You have most
likely seen or heard about this project on TV programs such as 20/20
and Oprah or you may have read about it in the Wall Street Journal.

Here are the 4 easy steps to success:

STEP 1:
Take a few minutes to join PayPal: www.paypal.com

When creating your PayPal account make sure you use the same Email
address as your user name in the list below so people can send money
to your account.

STEP 2
Once you have a PayPal account running. Send $1.00 dollar donation
from your PayPal account to THE FIRST e-mail address on the list
along
with a note saying "Please add me to your list". Then use PayPal to
post $1 to EACH of the additional 5 Email Addresses below because you
pay people with an email address in PayPal.

To do this you may need to use a credit card, which is very easy, and
secure so nobody but PayPal may see it. If you don't have a credit
card show this great lucrative offer to someone that has one and get
them to help you pay the $6.

There are the 6 individual Email addresses that you have to send $1 to
through PayPal for this to work properly and for you to receive
money.

Now send $1 to each of these following emails. These email addresses
are PayPal IDs or usernames.

1)
2) <o> </o>

3)
4)
5)
6)

STEP 3
Now,... after paying $1.00 to each of the email placements above, take
the #1 Email Address off the list, move the other Email Addresses up
(6 becomes 5, 5 becomes 4, etc.) and add Your Email Address as number
6 on the list.

STEP 4
Change anything you need to, but try to keep this article as close to
the original as possible.
Now, post your amended article to at least 200 newsgroups (there are
thousands of groups).

And email your message to as many people you can. Remember, the more
you post and email the more money you make! This is perfectly legal!
You then insert your Email Address into the list and it will move up
geometrically. So that when your name reaches the #1 position you will
have potentially received thousands of dollars into your account!!!

HOW TO POST TO NEWS GROUPS:
Use Netscape or Internet Explorer and try searching for various
newsgroups (on-line forums, message boards, chat sites, discussions.)

Log on any search engine like yahoo.com, google.com, altavista.com,
excite.com, etc., then search with the subject ''millionaire message
board'' or ''money making message board'' or ''employment message
board'' or ''money making discussions'' or ''money making forum'' or
''business message board'' etc.

You will find thousands and thousands of message boards.

Click on them one by one and you will find the option 'post a new
message'. Then Post this article as a 'new message' by highlighting
the text of this letter and selecting copy then paste from the edit
menu.

Fill in the Subject, this will be the header that everyone sees as
they scroll through the list of postings in a particular group, click
the
post message button.

You're done with your first one! It only takes about 60 seconds to
complete postings on message boards after you catch on.

REMEMBER, THE MORE NEWSGROUPS YOU POST IN, THE MORE MONEY YOU WILL
MAKE!!

You will begin receiving money in your account from around the world
within days!
mringrate is offline   Reply With Quote
Old 09-15-2008, 06:50 AM   #7
mringrate
Junior Member
 
Join Date: Sep 2008
Posts: 3
Default Add Me To Your List

MAKE $250,000 IN WEEKS using PAYPAL

AS SEEN ON OPRAH AND 20/20
**Proven by various, highly-respected U.S. TV and Radio programs as
being 100% legal, feasible and true. **
**Oprah Winfrey and ABC's investigation team 20/20 also prove it can
be done.***

THIS REALLY CAN MAKE YOU EASY MONEY!! IT WORKS!!! BUT YOU HAVE TO
FOLLOW The LETTER FOR IT TO WORK!!!! THIS IS NOT A PYRAMID SCAM!! :
I came across an article similar to this that said you could make
thousands of dollars within weeks with only an initial investment of
$6.00!

...here's how!

PayPal verifies that this $6 investment program is 100% legal and is a
big hit this year see their note below or ask them directly...

For a simple investment of 15-30 minutes and just $6, it is 100% worth
it to make thousands so quickly. This is not another scam that takes
lots of your hard earned money; this is a no risk investment that will
make you thousands of dollars very easily and quickly.

Turn $6 into $15,000 in only 30 days...here's how! You have most
likely seen or heard about this project on TV programs such as 20/20
and Oprah or you may have read about it in the Wall Street Journal.

Here are the 4 easy steps to success:

STEP 1:
Take a few minutes to join PayPal: www.paypal.com

When creating your PayPal account make sure you use the same Email
address as your user name in the list below so people can send money
to your account.

STEP 2
Once you have a PayPal account running. Send $1.00 dollar donation
from your PayPal account to THE FIRST e-mail address on the list
along
with a note saying "Please add me to your list". Then use PayPal to
post $1 to EACH of the additional 5 Email Addresses below because you
pay people with an email address in PayPal.

To do this you may need to use a credit card, which is very easy, and
secure so nobody but PayPal may see it. If you don't have a credit
card show this great lucrative offer to someone that has one and get
them to help you pay the $6.

There are the 6 individual Email addresses that you have to send $1 to
through PayPal for this to work properly and for you to receive
money.

Now send $1 to each of these following emails. These email addresses
are PayPal IDs or usernames.

1)
2)
3)
4)
5)
6)

STEP 3
Now,... after paying $1.00 to each of the email placements above, take
the #1 Email Address off the list, move the other Email Addresses up
(6 becomes 5, 5 becomes 4, etc.) and add Your Email Address as number
6 on the list.

STEP 4
Change anything you need to, but try to keep this article as close to
the original as possible.
Now, post your amended article to at least 200 newsgroups (there are
thousands of groups).

And email your message to as many people you can. Remember, the more
you post and email the more money you make! This is perfectly legal!
You then insert your Email Address into the list and it will move up
geometrically. So that when your name reaches the #1 position you will
have potentially received thousands of dollars into your account!!!

HOW TO POST TO NEWS GROUPS:
Use Netscape or Internet Explorer and try searching for various
newsgroups (on-line forums, message boards, chat sites, discussions.)

Log on any search engine like yahoo.com, google.com, altavista.com,
excite.com, etc., then search with the subject ''millionaire message
board'' or ''money making message board'' or ''employment message
board'' or ''money making discussions'' or ''money making forum'' or
''business message board'' etc.

You will find thousands and thousands of message boards.

Click on them one by one and you will find the option 'post a new
message'. Then Post this article as a 'new message' by highlighting
the text of this letter and selecting copy then paste from the edit
menu.

Fill in the Subject, this will be the header that everyone sees as
they scroll through the list of postings in a particular group, click
the
post message button.

You're done with your first one! It only takes about 60 seconds to
complete postings on message boards after you catch on.

REMEMBER, THE MORE NEWSGROUPS YOU POST IN, THE MORE MONEY YOU WILL
MAKE!!

You will begin receiving money in your account from around the world
within days!
mringrate is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump