P:\test>perl -MO=Deparse 376142-dl.pl >376142.pl 376142-dl.pl syntax OK #### if ($line =~ /$atomid.*\s*\w+\s+$resid\s+$atomidmatch.* \w+\s+$residmatch\s+\d\./ or $line =~ /$atomidmatch.*\s*\w+\s+$residmatch\s+$atomid.* \w+\s+$resid\s+\d\./) { print OUTFILE "array2[$el]\n"; last; } #### sub outputIf { my( $line, $atomid, $atomidmatch, $residmatch, $resid, $array2_el, $outfile) = @_; if ($line =~ /$atomid.*\s*\w+\s+$resid\s+$atomidmatch.* \w+\s+$residmatch\s+\d\./ or $line =~ /$atomidmatch.*\s*\w+\s+$residmatch\s+$atomid.* \w+\s+$resid\s+\d\./ ) { print $outfile "array2_el\n"; return 1; } return 0; } #### last if outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el], \*OUTFILE ); #### if ($array2[$el + 10] =~ /resid (\d+) and name (H\w+\d*).?\)/ and $array2[$el ] =~ /resid (\d+) and name (H\w+\d*).?\)/) { $resid = $1; $atomid = $2; if ($array2[$el + 10] =~ /resid (\d+) and name (H\w+\d*).\n?\)/) { $residmatch = $1; $atomidmatch = $2; } die "Can't open $distfil\ne" unless open DISTFILE, "$distfile"; while (defined($_ = )) { $line = $_; last if outputIf( $line, $atomid, $atomidmatch, $residmatch, $resid, $array2[$el] ); if ($array2[$el + 11] =~ /resid (\d+) and name(H\w+\d*).?\)/) { last if outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el] ); } elsif ($array2[$el + 12] =~ /resid (\d+) and name(H\w+\d*).?\)/) { last if outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el] ); } elsif ($array2[$el + 13] =~ /resid (\d+) and name(H\w+\d*).?\)/) { last if outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el] ); } elsif ($array2[$el + 14] =~ /resid (\d+) and name(H\w+\d*).?\)/) { last if outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el] ); } elsif ($array2[$el + 15] =~ /resid (\d+) and name(H\w+\d*).?\)/) { last if outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el] ); } } } #### @array2 = ; chomp @array2; foreach $el ( 0 .. @array2 ) { next if whileif( \@array2, $el, 10, $distfile, $outfile ); next if whileIf( \@array2, $el, 11, $distfile, $outfile ); next if whileIf( \@array2, $el, 12, $distfile, $outfile ); next if whileIf( \@array2, $el, 13, $distfile, $outfile ); next if whileIf( \@array2, $el, 14, $distfile, $outfile ); next if whileIf( \@array2, $el, 15, $distfile, $outfile ); print OUTFILE "$array2[$el]\n"; } #### sub whileIf { my( $arrayRef, $el, $offset, $distfile, $outfile ) = @_; if ($array2[$el + $offset] =~ /resid (\d+) and name (H\w+\d*).?\)/ and $array2[$el ] =~ /resid (\d+) and name (H\w+\d*).?\)/) { $resid = $1; $atomid = $2; die "Can't open $distfil\ne" unless open DISTFILE, "$distfile"; WHILELOOP: while( defined( $line = ) ) { for my $offset2 ( 0 .. 5 ) { last WHILELOOP if $array2[$el + $offset] =~ /resid (\d+) and name (H\w+\d*).\n?\)/ and outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el], $outfile ) ; } } return 1; } return 0; } #### $katfile = '/remote/belgarath/tpukala/pegasus/xplor/signif/25jun2.kat2'; $outfile = 'temp.kat'; die "Can't open $outfile" unless open OUTFILE, ">$outfile"; die "Can't open $katfile" unless open KATFILE, "$katfile"; @array = ; chomp @array; $numelements = @array; @arraylist = 0 .. $numelements; foreach $el (@arraylist) { if ($array[$el] =~ /^\)$/ and $array[$el + 1] =~ /^\($/) { print OUTFILE ")\n*\n*\n*\n*\n*\n*\n*\n"; } elsif ($array[$el] =~ /assign/ and $array[$el + 1] =~ /^\($/) { print OUTFILE "assign\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"; } else { print OUTFILE "$array[$el]\n"; } } close KATFILE; close OUTFILE; $distfile = "/remote/belgarath/tpukala/pegasus/xplor/signif/25jun/rnk_2\n5jun_signif_.dst"; $katfile = '/remote/belgarath/tpukala/pegasus/xplor/signif/temp.kat'; $outfile = 'temp2.kat'; die "Can't open $outfile" unless open OUTFILE, ">$outfile"; die "Can't open $katfile" unless open KATFILE, "$katfile"; @array2 = ; chomp @array2; foreach $el ( 0 .. @array2 ) { whileif( \@array2, $el, $_, $distfile, \*OUTFILE ) and next for 10 .. 15; print OUTFILE "$array2[$el]\n"; } close KATFILE; close OUTFILE; $katfile = '/remote/belgarath/tpukala/pegasus/xplor/signif/temp2.kat'; $outfile = 'half.kat'; die "Can't open $outfile" unless open OUTFILE, ">$outfile"; die "Can't open $katfile" unless open KATFILE, "$katfile"; @array3 = ; chomp @array3; $numelements3 = @array3; @arraylist3 = 0 .. $numelements3; foreach $el (@arraylist3) { if ($array3[$el] =~ /^\*$/) { (); } elsif ($array3[$el] eq $array3[$el + 1]) { (); } else { print OUTFILE "$array3[$el]\n"; } } ## Exit main program exit; sub outputIf { my( $line, $atomid, $atomidmatch, $residmatch, $resid, $array2_el, $outfile ) = @_; if ($line =~ /$atomid.*\s*\w+\s+$resid\s+$atomidmatch.* \w+\s+$residmatch\s+\d\./ or $line =~ /$atomidmatch.*\s*\w+\s+$residmatch\s+$atomid.* \w+\s+$resid\s+\d\./ ) { print $outfile "array2_el\n"; return 1; } return 0; } sub whileIf { my( $arrayRef, $el, $offset, $distfile, $outfile ) = @_; if ($array2[$el + $offset] =~ /resid (\d+) and name (H\w+\d*).?\)/ and $array2[$el ] =~ /resid (\d+) and name (H\w+\d*).?\)/) { $resid = $1; $atomid = $2; die "Can't open $distfil\ne" unless open DISTFILE, "$distfile"; WHILELOOP: while( defined( $line = ) ) { for my $offset2 ( 0 .. 5 ) { last WHILELOOP if $array2[$el + $offset] =~ /resid (\d+) and name (H\w+\d*).\n?\)/ and outputIf( $line, $atomid, $atomidmatch, $1, $2, $array2[$el], $outfile ) ; } } return 1; } return 0; }