Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Extracting array of hashes from data

by Abigail (Deacon)
on Jun 10, 2001 at 17:42 UTC ( #87291=note: print w/replies, xml ) Need Help??


in reply to Extracting array of hashes from data

#!/opt/perl/bin/perl -w use strict; my %keys = (map ({$_ => "SCALAR"} qw /ID TITLE GENE CYTOBAND LOCUSLINK CHROMOSOME SCOUNT/), map ({$_ => "ARRAY"} qw /EXPRESS/), map ({$_ => "HASH"} qw /SEQUENCE PROTSIM/)); my %alldata; while (<DATA>) { chomp; my ($key, $value) = split /\t+/ => $_, 2; if ($keys {$key} eq "SCALAR") {$alldata {$key} = $value} elsif ($keys {$key} eq "ARRAY") { $value =~ s/^;+//; $alldata {$key} = [split /;/ => $value]; } elsif ($keys {$key} eq "HASH") { push @{$alldata {$key}} => {map {split /=/} split /;\s*/ => $v +alue}; } else { die "Unknown key $key found in data.\n" } } __DATA__

-- Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://87291]
help
Chatterbox?
[LanX]: oh there is even an Elsassian version ... =)
[Eily]: I don't think there's any link between the name and the character in the french version
[Eily]: Elsassian? Is that the language of Elsa?
[LanX]: Obelix?
Eily runs to safety
[LanX]: https://en. wiktionary.org/ wiki/Elsassian
[Eily]: LanX Assurantourix
[karlgoethebier]: Lanx: nit picking: isn't it "les petits-bourgeois"?
Eily learned about Elsass
LanX doesnt care about orthografix

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2017-05-24 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?