in reply to Re: problems with pattern match
in thread SOLVED:problems with pattern match

Thank you, but I tried but it doesn't work...It only print legami idrofobici: legami idrogeno: so the script runs but it doesn't do what I want...

#!/usr/local/bin/perl use strict; use warnings; use LWP::Simple; open (IN, "</home/nerone/Desktop/lig/1xmj.pl") || die "impossibile apr +ire il file"; 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/) { push @residue , $r; } } printf "legami idrofobici: %s\n" , join '' , @hydrophobic; printf "legami idrogeno: %s\n" , join '' , @residue; __DATA__

I don't know well that synthax....but it doesn't work

Replies are listed 'Best First'.
Re^3: problems with pattern match
by parv (Parson) on Apr 21, 2009 at 11:57 UTC

    [...] I tried but it doesn't work...It only print legami idrofobici: legami idrogeno: so the script runs but it doesn't do what I want.

    ... open (IN, "</home/nerone/Desktop/lig/1xmj.pl") || die "impossibile apr +ire il file"; my ( @hydrophobic , @residue ); while ( my $r = <DATA> ) { ... }

    I used DATA file handle so that portion of your own input could be appended to the program itself to form self contained example. Given your changes, the program expectedly did not print anything. Please read about open function and DATA file handle (under "Special Literals" subsection).

    You need to replace DATA file handle with IN (not the other way around) and try again.

    After seeing "SOLVED" & posted code in OP: emphasised the replacement & added parenthetical clarification for good measure. *sigh*