On Sat, Jun 9, 2012 at 12:16 AM, lina <[email protected]> wrote:
> Hi,
>
> Here is the to-be-processed file,
>
> $ more try
> # RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N
> N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA
> Z-CA
> 1 174 V 0 0 0 0, 0.0 2,-0.3 0,
> 0.0 0, 0.0 0.000 360.0 360.0 360.0 137.8 47.8 27.7 76.9
> 2 175 H - 0 0 0 2,-0.0 2,-0.3 0,
> 0.0 0, 0.0 -1.000 360.0-153.6-152.0 146.1 50.8 25.5 78.2
>
> I wish to print the value under the BP1, namely
>
> 0
> 0
>
> but no matter count from left or right, the field number is uncertain,
>
> Thanks ahead for your suggestions,
>
> Here is the one I come up so far,
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use autodie qw(open close);
> use 5.012;
>
> my $filename = "try";
>
> open my $fh, '<', $filename;
>
> while(my $line = <$fh>){
> if($line =~ /^\s+ (1|2)/ && $line =~ /\d$/) {
>
Seems this way work
if($line =~ /([ -]\d,[ -]\d+)/) {
say $1;
If you have good solutions, please feel free to let me know.
Thanks with best regards,
> my @fields = split ' ', $line;
> #say $fields[-12], "\t", $fields[-11];
> ;
> }
>
> }
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/