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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

uninitialized value in substitution iterator 1

Status
Not open for further replies.

JohnLucania

Programmer
Oct 10, 2005
96
US
my @SeqChar;
print "Enter sequences and 'enter' and then Ctrl + D: ";
chomp(@SeqChar = <STDIN>);

sub trans {
my %translate = (
'aug' => 'asn',
'uag' => 'cya',
'gcu' => 'tis',
'aag' => 'lis',
'atg' => 'phe'
);
for( @SeqChar ){
tr/atcg/uagc/;
s/(...)/$translate{$1}/g;
print $_,"\n";
}
}

trans();

Why am I getting these errors?

./tchar.pl
Enter sequences and 'enter' and then Ctrl + D: atgatg
Use of uninitialized value in substitution iterator at ./tchar.pl line 19, <STDIN> line 1.
Use of uninitialized value in substitution iterator at ./tchar.pl line 19, <STDIN> line 1.

jl
 
Because your variable

$translate{$1}

translates to UNDEFINED because $1 doesn't match any of your %translates Keys .

Your Input

atgatg

is translated to

uacuac

by the tr/atcg/uagc/

And uac doesn't have a translation.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top