ActiveState Powered by ActiveState

ActiveState Community


spliting a table into individual columns

Posted by C_elegance on 2007-12-19 20:04
OS: OS X

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=){
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

Thank a million
x

-->