First, it would help if you posted the full code, including the diagnostic statements
e.g.
@fileList = readdir(DIR);print "filelist=@fileList\n";
Second, I am not sure a space is allowed between
Bio::SeqIO ->new, but I guess it's ok
Thirs, you can always try
perk -d:

tkdb yourscript.pl
This is a visual debugging interface and you can trace what your code does
(You need of course to install the module ptkdb first

)
Fourth, I suggest using strict and mying all your variables. If $input and $format will not be modified by the subroutine(as it looks like), then please call the subroutine
as access_seq($format,$input,$file,\$found,\@foundfile);
and then have
sub accessA_seq{my $format=shift;my $input =shift;
my $file=shift; my $rfound=shift;my $rfoundfiles=shift;
$in = Bio::SeqIO ->new(-file =>"$file",'-format'=>"$format"

; you do not need the quotes "$file"
and "$format"
Last, and here is the answer it is obvious that the infinite loop is in
while (my $seq = $in->next_seq()) {
my @sequence = $seq->seq;
}
if (@sequence = ~/$input/) {
#$input is a user input.
print "Sequence found in ",$file,"\n";
push @foundfile,$file;
$found = $found + 1;
}
Here note thatyour check criterion will be true if
the number of elements in @sequence includes a string $input, e.g. igf you have 1000 elements in @sequence, then if $input is ffggf100055965yiutu, then you have a match
Is this really what you want, or are you trying to say: If @sequence contains an element $input, then...
The reason is that
@sequence is an array and you are evaluating it in a scalar context
I am not familiar with the specific module, nor do I have it installed, but how does the while condition become false?
Here is my further suggestion. This will not give you a working code, but it will tell us what your code is doing. Please try it and post the printout
I realize you do not want to use references and stuff, so
I am deliberately keeping the code with
as few changes from your original as possible
Pleas epost the outcome
svar
#####
#debugging rewrite
$input= .... ;
$format=....;
$database= ...;
@foundfile=();
$found=0;
@filelocation = Location::destination ($database);
$location = $filelocation[0];
chdir $location or die "cannt chdir to $location\n";#always check for errors!
opendir (DIR, "$location"

|| die "Couldn't open directory \n";
@fileList = readdir(DIR);
print "filelist=@fileList\n";
foreach my $file (@fileList) {
#...do something with the files..
&access_seq(); }
sub access_seq {
$in = Bio::SeqIO ->new(-file =>$file,'-format'=>$format);
while (my $seq = $in->next_seq()) {
my @sequence = $seq->seq;
}
print "sequence =@sequence\n";
my $ref=ref($seq}\n";
print "ref=$ref\n";
die;
if (@sequence = ~/$input/) {
#$input is a user input.
print "Sequence found in ",$file,"\n";
push @foundfile,$file;
$found = $found + 1;
}
}