I have a subroutine outputs an array like this
ATOM 1276 CB ASP B 63 52.957 58.788 67.683 1.00 44.59 C
ATOM 1280 N GLY B 64 52.075 55.496 66.522 1.00 35.29 N
ATOM 1281 CA GLY B 64 51.005 54.534 66.322 1.00 32.64 C
ATOM 1282 C GLY B 64 49.693 55.103 65.854 1.00 30.87 C
ATOM 1283 O GLY B 64 48.630 54.545 66.092 1.00 27.93 O
ATOM 1284 N LYS B 65 49.739 56.255 65.189 1.00 31.10 N
ATOM 1285 CA LYS B 65 48.527 56.912 64.720 1.00 33.91 C
ATOM 1286 C LYS B 65 48.629 57.147 63.216 1.00 32.04 C
ATOM 1287 O LYS B 65 49.675 57.571 62.721 1.00 31.87 O
here each line is an element of an array, but i need only certain columns of this output. for example the first row is all ATOM, but i do not need any of that, could anyone please tell me, how to extract the required rows, a simple psuedocode would help me a lot.
UPDATE #1
ok i used the regular expressions code that was suggested and I am facing a problem with the output, the array in the output is empty, could some one tell me where I am going wrong
the code is after i get the array from the subroutine, the array consists of the output as the format above and every line of the output is a single element of the array. If i type $line1 i get the first line.
my @opin = &attributes(); my @lines = @opin; my ($selected, @selections); for my $lines(@lines) { if ( $lines =~ /ATOM\s+ \d+\s+ ([A-Z]{1,2})\s+ ([A-Z]{3})\s+ [AB]\s+ \d+\s+ \d+\.\d+\s+ \d+\.\d+\s+ \d+\.\d+\s+ \d+\.\d+\s+ \d+\.\d+\s+ [CNO]$/x ) { $selected = $1 . " | " . $2 ; push @selections, $selected; } } print O "@selections"; close (O); close (I);
any help would be appreciated.
In reply to newbie need help with a simple code by perlmonk007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |