Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is this not entering the loop at all? 1

Status
Not open for further replies.

axelro

Technical User
Nov 19, 2008
3
0
0
GB
my $aa = <>;

my %a = (
ALA => "A",
ARG => "R",
ASN => "N",
ASP => "D",
ASX => "B",
CYS => "C",
GLU => "E",
GLN => "Q",
GLX => "Z",
GLY => "G",
HIS => "H"
);

foreach my $key (keys %a) {
if ($aa eq $key) {
my $b = $amin{key};
print $b, "\n";
}
}
 
It must be entering the loop, but maybe you need to chomp() $aa before trying to match one of the hash keys.

$aa = <>;
chomp($aa);

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Where is $amin{} coming from. Please do not use $a, or $b as variables and use strict!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top