[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Re: Beginner Question



rmeister@MTS.Net, mac-perl@iis.ee.ethz.ch
Subj:	[MacPerl] Re: Beginner Question


Tristan J. Meisters wrote:

> I have looked through the code and I cannot find anything that is
> syntacticly wrong with the code, especially right before the else block. I
> seem to remember having the same problem once before when I was using the
> else clause. Anyway, below is a copy of my code, any help would be greatly
> appreciated.

It took me a while too - you were missing a semi-colon ';' after the  
statement:

> 	my ($num) = @_				#initalize the look-up number

it _might_ have been written:

 	my ($num) = @_;				#initalize the look-up number

But I think that you want to do this instead:

#!perl   -w

use strict;

my $num ;

sub num_return  {
    my @equiv = qw (zero one two three four five six seven eight nine);
 
    my $num = shift;

    if ($equiv[$num])   {			# test if number is defined
        return $equiv[$num];
    } else {
        return $num;
    }
}

while (defined(chomp($num = <STDIN>)))	{
    print("The written equivalent of $num is ",num_return($num)," !\n");
}


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch