Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: storing a file in 2d array

by johngg (Canon)
on May 01, 2020 at 10:12 UTC ( #11116308=note: print w/replies, xml ) Need Help??

in reply to storing a file in 2d array

It might be that the fields are TAB separated but I see no evidence for that in the page source, just multiple SPACE characters. If that reflects reality then this code might do the trick.

johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<__EOD__ or die $!; ProteinName MF1 MF2 MF3 GH1 Growth factor activity Growth hormone receptor binding Ho +rmone activity POMC G protein-coupled receptor binding Hormone activity Sign +aling receptor binding THRAP3 ATP binding Source Nuclear receptor transcription coactiv +ator activity Phosphoprotein binding __EOD__ chomp( my @lines = grep { ! m{^ProteinName} } <$inFH> ); close $inFH or die $!; say join q{; }, split m{\s{2,}} for @lines;' GH1; Growth factor activity; Growth hormone receptor binding; Hormone +activity POMC; G protein-coupled receptor binding; Hormone activity; Signaling +receptor binding THRAP3; ATP binding Source; Nuclear receptor transcription coactivator + activity; Phosphoprotein binding

I hope this is helpful.

Update: I should have looked at the download link, they are TABs, so changing m{\s{2,}} to m{\t} would work.



Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2023-01-31 14:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found