I'm trying to understand an example from the Waite Press book (Perl 5
Interactive Course, a bit dated, '97, Orwant)  The example doesn't have -w
or strict; enabled.  I ran it with them and the error follows:

#!c:/perl/bin/perl -w
use strict;

print "Please type an integer: ";
chomp ( my $num = <STDIN>);
while ( $num != 1 ) {
    print "$num";
    if ( ( $num % 2 ) == 0 ) { $num /= 2 }  # so if it's even, or divisible
by 2, divide by 2
    else { $num * 3; $num++; }    #multiply the number entered by 3(?), then
increment(?)
}
print $num, "\n";   # I tried with and without the \n and the output never
rendered differently?
#push (my @numbers, $num); print '@numbers'; 

Error:  Useless use of multiplication in void context at
C:\WINNT\Profiles\moi\Desktop\perl\lesson4\mea
nder.pl line 9.
Please type an integer:

Please type an integer: 35
353618910563421

The example is simply there to teach a looping construct, (it could be just
a bad example..I doublechecked my typing, but my error is invisible to me at
this point....) 

?'s:
What's void context?.  I've seen it referenced using perldoc -q void, but
don't quite follow the answers in perldoc?

thanks in advance,
Rob
--
Rob McCormick
GlaxoSmithKline 
[EMAIL PROTECTED] 


Reply via email to