Your problem is that $i is only changed if $answer eq $numbers[$i]. You need to increment $i all the time. Or better, use a hash:
#usr/bin/perl use strict; use warnings; my %numbers = qw( 0 zero 1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 eight 9 nine ); print "Enter a number\n"; chomp( my $input = <STDIN> ); print $numbers{ $input } if exists $numbers{ $input };
In reply to Re: Sub Routine Malfunction
by jwkrahn
in thread Sub Routine Malfunction
by koolgirl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |