H!
it's my first message, and i'm a total beginner. I'm trying to split a table into individual columns (and i think i've done it) but how go i extract the data from the individual column and/or search them for certain data, like type?
use warnings; use strict; sub read_TABLE{ my($file_name)=@_; open (OPEN_TABLE,$file_name); if(open (OPEN_TABLE, $file_name)){ print "Can open file \"$file_name\" \n"; } unless(open(OPEN_TABLE, $file_name)){ print STDERR "Can't open file \"$file_name\" \n"; } my@table; while(my$line=<OPEN_TABLE>){ chomp$line; my@data=split(/\t/,$line,5); push@table,\@data; } close OPEN_TABLE; return @table; } my@s=&read_table("TABLE.txt"); foreach my$line(@s) { my$start=[0]; my$end=[1]; my$name=[2]; my$strand=[3]; my$type=[4]; print "$type\n"; }
one of the columns has tells me whether it's a promoter (DNA data). i want to fish out all "promoters", match them to the name and sequence start and end description other columns so i can fish out the sequence from different file.
can you help?
also when i run it i get:
Can open file "TABLE.txt" ARRAY(0x181ea88) ARRAY(0x181ea88) ARRAY(0x181ea88) ARRAY(0x181ea88) ARRAY(0x181ea88) ..... ARRAY(0x181ea88)
what does it mean?? it looks like some sort of reference??

actually i've just tested whether it's a reference with

print "@$type\n";
and yes, i get
Can open file "TABLE.txt" 4 4 4 4 etc
which means that i created a column called "type" full of 4s rather then an array of data from 5th column arrrrrrr

Since this morning i've tried other ways but still nothing, please help, i losing will to live or brewing a computer rage, i don't know what worst, one's sure i feel right idiot!!

Thank a million
x


In reply to spliting a table into individual columns by C_elegance

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.