in reply to
Re^3: reading and working with grow.out files
in thread reading and working with grow.out files
I made this program, but it is giving so many errors. Can you help me in debugging it.
use strict;
use warnings;
use Carp qw(croak);
{
my $input_file = "input_file.txt";
my @lines = slurp($input_file);
for my $line (@lines){
my ($filename, $ligand) = split(/\t/, $line);
open(FILE, '<', $filename) or die "Cannot open file: $!";
while (my $line = <FILE>) {
if ($line =~ /$ligand/)
{
$count++;
$first=substr($line, 0,1);
if($first=='H');
{
$sum++;
}
}
print "Total No. of interactions are $count";
print " No. of Hydrogen bonds are $sum";
}
close(FILE);
}
}
##Slurps a file into a list
sub slurp {
my ($file) = @_;
my (@data, @data_chomped);
open IN, "<", $file or croak "can't open $file\n";
@data = <IN>;
for my $line (@data){
chomp($line);
push (@data_chomped, $line);
}
close IN;
return (@data_chomped);
}