Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: MCE: How to access variables globally

by Marshall (Canon)
on Dec 21, 2021 at 11:07 UTC ( [id://11139800]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139800]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2026-04-14 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.