John Ravich writes:
> It's only my third day with Perl
and your third identical message. Careful now :-)
> ... I am
> working in the Komodo development environment on
> Windows 2000. I am trying to get a user input for the
> radius and then, calculate the circumpherence of the
> circle ( exercise 2-2 from the Lama book). Here is the
> code:
>
> $radius =<STDIN>;
> $circum = $radius * 2 * 3.14;
> print "The circumference of the circle with the
> radius of $radius equals $circum\n";
>
> It doesn't ask me for input and just kind of
> hangs.
> Can I use <STDIN> in Komodo? How ?
> Thanks.
Thats probably because you didn't tell perl to ask you for input. It
probably is waiting though. The way I might do this, if it helps, is
as follows
---------------------------------------------
use strict; # Always use
use warnings; # Always use, (or -w switch)
use constant PI => 4 * atan2 1, 1; # see `perldoc constant`
sub get_response {
my $prompt = shift;
local $| = 1; # autoflush, see `perldoc perlop`
print $prompt;
my $reply = <STDIN>;
chomp $reply;
return $reply;
}
my $radius = get_response "Enter radius: ";
my $circum = $radius * 2 * PI;
print "The circumference of the circle with the radius of $radius equals $circum\n";
---------------------------------------------
HTH
--
Brian Raven
: I could understand principles of Perl source in 2-3 days [. . .]
Gee, it took me about eleven years. :-)
-- Larry Wall in <[EMAIL PROTECTED]>
-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely
for the intended addressee(s). Unauthorised reproduction, disclosure,
modification, and/or distribution of this email may be unlawful. If you
have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message
do not necessarily reflect those of
LIFFE Holdings Plc or any of its subsidiary companies.
-----------------------------------------------------------------------
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs