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 ...

In reply to Re: problems with pattern match by parv
in thread SOLVED:problems with pattern match by paola82

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.