Hashes

Examples



%prices = ("shirt"    => 45,
           "pullover" => 90,
           "trousers" => 120,
           "socks"    => 15);
           
%genetic_code = ("TGT" => "Cys",       #partial list
                 "TGC" => "Cys",
                 "GAT" => "Asp",
                 "GAC" => "Asp",
                 "GAA" => "Glu",
                 "GAG" => "Glu",
                 "TTT" => "Phe");

                 
%student = ("name"       => "Kelly",
            "faculty"    => "Faculty of Medicine",
            "degree"     => "MSc",
            "phone"      => "4691",
            "email"      => "kelly.spinoza\@biu.ac.il");
                 
                 
Note that the hash keys should be unique! For instance, you could not write the %genetic_code hash such that amino acids point to codons, due to redundancy.

You may use scalar variables instead of literal strings. e.g.

%gene = ("name"             => $gene_name,
         "description"      => $gene_desc,
         "cDNA sequence"    => $cDNA_seq,
         "genomic sequence" => $genomic_seq);

Table of Contents.
Previous | Next.