develooper Front page | perl.beginners | Postings from April 2010

how to create a hash on the fly

Thread Next
From:
raphael.japh
Date:
April 14, 2010 21:59
Subject:
how to create a hash on the fly
Message ID:
k2ka81c2f2d1004142159re512a8ddpf08641901d385f0e@mail.gmail.com
Hello People,
I am stuck on a minor problem. How can I create a hash?

Data is as follow

---------- DATA ----------

# abc      <-- this_should_be_hash_name

{space} "random_name_or_number"  "date"  "other_things_1" "other_things_2"
{space} "random_name_or_number"  "date"  "other_things_1" "other_things_2"

# xyz      <-- this_should_be_a_new_hash_name (second_hash)

{space} "random_name_or_number"  "date"  "other_things_1" "other_things_2"

---------- END ----------

How can I create a hash by the name that matches

m/^#(?:\s+)?(\S+)$/

The hash should be created by the name of "$1" i.e (\S+)$
like if "$1" is 'abc' the hash should be %abc which will later be filled by
keys & values
that are matched in the next line. Thus hash should be created beforehand.

Am I making this clear?

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About