in reply to Re^4: MCE: How to access variables globally
in thread MCE: How to access variables globally

This is a separate post with a program to use the DB from the previous post.
You could make a Perl hash table to calculate a histogram of say the State1 column. However we can just ask SQL to do that for us and give us the results in descending order of frequency. The DB will figure out how to do this within the memory that it has to work with.

My "SQL kung-foo" is not very advanced, but some really amazing things can be done with SQL when coded by an expert.

use strict; use warnings; use DBI; ############ # let's say you want a histogram of State1 ############ my $dbfilename = "biohisham.sqlite"; my %attr = ( RaiseError => 1); #auto die with error printout my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfilename","","",\%attr) or die "Couldn't connect to database $dbfilename: " . DBI->errstr; my $get_state1_histo = $dbh->prepare("SELECT count(*),State1 FROM bioham GROUP BY State1 ORDER BY count(*) DESC"); $get_state1_histo->execute(); my $array_ref = $get_state1_histo->fetchall_arrayref; foreach my $row_ref (@$array_ref) { print "@$row_ref\n"; } __END__ 12 VEGF -- IL_8 -- Ang_2 -- TSP1_2 -- Maspin -- Invasiveness_migration + -- Senescence -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_le +akiness -- Enolase_1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 6 VEGF -- IL_8 -- Ang_2 -- TSP1_2 -- Invasiveness_migration -- Senesce +nce -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- +Enolase_1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 4 VEGF -- IL_8 -- Ang_2 -- Maspin -- Invasiveness_migration -- Senesce +nce -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Enolase_1 -- S6k1 -- Hmox +-- TWIST1 -- Erythropoietin 3 VEGF -- IL_8 -- Ang_2 -- TSP1_2 -- Maspin -- Invasiveness_migration +-- Senescence -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_lea +kiness -- Enolase_1 -- Hmox -- TWIST1 -- Erythropoietin 3 VEGF -- IL_8 -- Maspin -- Invasiveness_migration -- Senescence -- Gl +ut1_4 -- P21 -- BCL_XL -- LDHA -- Enolase_1 -- Hmox -- TWIST1 -- Eryt +hropoietin 2 VEGF -- Ang_2 -- TSP1_2 -- Maspin -- Invasiveness_migration -- Senes +cence -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_leakiness - +- Enolase_1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 2 VEGF -- IL_8 -- Ang_2 -- TSP1_2 -- Maspin -- Senescence -- Glut1_4 - +- P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- Enolase_1 -- S6k +1 -- Hmox -- TWIST1 -- Erythropoietin 1 Ang_2 -- Maspin -- Invasiveness_migration -- Senescence -- Glut1_4 - +- P21 -- BCL_XL -- LDHA -- TWIST1 -- Erythropoietin 1 IL_8 -- Ang_2 -- Invasiveness_migration -- Senescence -- Glut1_4 -- +P21 -- BCL_XL -- LDHA -- Enolase_1 -- TWIST1 -- Erythropoietin 1 IL_8 -- Ang_2 -- TSP1_2 -- Glut1_4 -- LDHA -- Permeability_leakiness + -- S6k1 1 IL_8 -- Maspin -- Glut1_4 -- P21 -- LDHA -- S6k1 -- Hmox -- TWIST1 - +- Erythropoietin 1 Invasiveness_migration -- Senescence -- Glut1_4 -- P21 -- BCL_XL -- +Ang_1 1 TSP1_2 -- Invasiveness_migration -- Senescence -- Glut1_4 -- BCL_XL +-- Permeability_leakiness -- Enolase_1 -- Ang_1 -- Erythropoietin 1 TSP1_2 -- Senescence -- Glut1_4 -- BCL_XL -- Enolase_1 -- Ang_1 -- T +WIST1 -- Erythropoietin 1 VEGF -- Ang_2 -- Invasiveness_migration -- Senescence -- Glut1_4 -- +Enolase_1 -- Hmox -- Erythropoietin 1 VEGF -- Ang_2 -- Maspin -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Enola +se_1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- Ang_2 -- TSP1_2 -- Invasiveness_migration -- Senescence -- G +lut1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- Enolase_ +1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- Ang_2 -- TSP1_2 -- Senescence -- Glut1_4 -- LDHA -- Enolase_ +1 -- Ang_1 -- S6k1 -- Hmox 1 VEGF -- Ang_2 -- TSP1_2 -- Senescence -- Glut1_4 -- P21 -- BCL_XL -- + LDHA -- Permeability_leakiness -- Enolase_1 -- S6k1 -- Hmox -- TWIST +1 -- Erythropoietin 1 VEGF -- IL_8 -- Ang_2 -- Invasiveness_migration -- Senescence -- Glu +t1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- Enolase_1 +-- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- IL_8 -- Ang_2 -- Maspin -- Invasiveness_migration -- Senesce +nce -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Enolase_1 -- Hmox -- TWIST +1 -- Erythropoietin 1 VEGF -- IL_8 -- Ang_2 -- Maspin -- Senescence -- Glut1_4 -- P21 -- B +CL_XL -- LDHA -- Enolase_1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoieti +n 1 VEGF -- IL_8 -- Ang_2 -- TSP1_2 -- Invasiveness_migration -- Glut1_4 + -- P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- Enolase_1 -- S +6k1 -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- IL_8 -- Ang_2 -- TSP1_2 -- Maspin -- Glut1_4 -- P21 -- BCL_X +L -- LDHA -- Permeability_leakiness -- Enolase_1 -- S6k1 -- Hmox -- T +WIST1 -- Erythropoietin 1 VEGF -- IL_8 -- Maspin -- Invasiveness_migration -- Senescence -- Gl +ut1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- Enolase_1 + -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- IL_8 -- TSP1_2 -- Maspin -- Invasiveness_migration -- Senesc +ence -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- + Enolase_1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- Maspin -- Glut1_4 -- P21 -- BCL_XL -- LDHA -- Enolase_1 -- S +6k1 -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- Maspin -- Invasiveness_migration -- Glut1_4 -- P21 -- BCL_XL + -- LDHA -- Ang_1 -- S6k1 -- Hmox -- TWIST1 -- Erythropoietin 1 VEGF -- TSP1_2 -- Invasiveness_migration -- Senescence -- Glut1_4 -- + P21 -- BCL_XL -- LDHA -- Permeability_leakiness -- Ang_1 1 VEGF -- TSP1_2 -- Maspin -- Invasiveness_migration -- Senescence -- +Glut1_4 -- P21 -- BCL_XL -- Permeability_leakiness -- Ang_1