in reply to SOLVED:problems with pattern match
Could you please adopt a style, any style, for your programs? See perlstyle for some guidance & search around here on the topic.
Problem is that you seem to have data on multiple lines that you are trying to match, but you are reading & matching only one line at a time. Try this ...
my ( @hydrophobic , @residue ); while ( my $r = <DATA> ) { if ( $r=~ m/Hydrophnam_size Center/ .. $r =~ /Hydrophnam_size/ ) { push @hydrophobic , $r; next; } if( $r=~ m/Nligresnam_size Center/ .. $r =~ /Nligresnam_size Print/) { push @residue , $r; } } printf "legami idrofobici: %s\n" , join '' , @hydrophobic; printf "legami idrogeno: %s\n" , join '' , @residue; __DATA__ ... % Hydrophobic contact Hydrophname_col Zero_linewidth W G Background_col 189.17 329.15 189.17 317.71 235.30 317.71 235.30 329.15 Pl4 212.23 323.43 moveto (Trp 401(A)) Hydrophnam_size Center (Trp 401(A)) Hydrophnam_size Print % Hydrophobic contact Hydrophname_col Zero_linewidth W G Background_col 404.14 338.82 404.14 327.38 450.28 327.38 450.28 338.82 Pl4 427.21 333.10 moveto (Val 440(A)) Hydrophnam_size Center (Val 440(A)) Hydrophnam_size Print ... % Residue names gsave Ligresname_col 244.91 185.50 moveto (Atp 1) Ligresname_size Center (Atp 1) Ligresname_size Print Nligresname_col 139.01 612.49 moveto (Lys 464(A)) Nligresnam_size Center (Lys 464(A)) Nligresnam_size Print Nligresname_col 133.08 424.57 moveto (Thr 465(A)) Nligresnam_size Center (Thr 465(A)) Nligresnam_size Print ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problems with pattern match
by paola82 (Sexton) on Apr 21, 2009 at 11:49 UTC | |
by parv (Parson) on Apr 21, 2009 at 11:57 UTC |