One way:

open(FOO,"filename") || die "Couldn't open filename: !$\n";
while(<FOO>) {
        chomp();
        ($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) = split;
        $interestingdata = join("|",$t4,$t5,$t6,$t7,$t8);
        $atomhash{$t2} = $interestingdata;
}

It would be more enlightening to name the variables so you
know what they are. To extract, you have to either walk through
the entire hash or selectively extract the ones you want.

Selective:

$wanttosee = $atomhash{$somenumber};

Everything:

while (($atom,$values) = each(%atomhash)) {
        ($t4,$t5,$t6,$t7,$t8) = split(/|\/,$values);
        # do something useful here. The print is a sample
        print "Atom number is $atom. Data are:\n"
        print "\t$t4\t$t5\t$t6\t$t7\t$t8\n";
}

Giff

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 08 March, 2005 05:52
To: beginners@perl.org
Subject: reading an file 

Hello!
I want to read this file into an array.
How can i just get 4, 5, 6,7,8 into an array?
And later, how can i get the contents out of this array?
1)            2)        3)       4)      5)                6)
7)            8)           9)    10)                11)
ATOM   2909  CG1   VAL B 183       1.130  28.458 104.360  1.00
23.04           C
ATOM   2910  CG2   VAL B 183       0.996  29.769 102.236  1.00
24.61           C
ATOM   2911  N       THR B 184       3.313  31.739 103.453  1.00
25.98           N
ATOM   2912  CA     THR B 184       3.261  33.012 104.149  1.00
29.31           C
ATOM   2913  C       THR B 184       1.911  33.642 103.859  1.00
29.26           C
ATOM   2914  O       THR B 184       1.442  33.626 102.720  1.00
28.75           O
regards


--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,
e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to